diff --git a/.stats.yml b/.stats.yml index b047b943714..b2f16faad0b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 2041 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml -openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: be3f6e9410db673744447f9dbe92d922 +configured_endpoints: 2095 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9bf0744b89b9fc316fbe50b005fa5f652dd08c79056789090d940e7a8a7d9202.yml +openapi_spec_hash: ff5ac2b0251d501b29346bdcb7df7599 +config_hash: 3197a7cbacf324269e77cfb812a38f53 diff --git a/api.md b/api.md index 3f5cd6f421a..113ffd881dc 100644 --- a/api.md +++ b/api.md @@ -1681,6 +1681,45 @@ Methods: - 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: @@ -2628,15 +2667,20 @@ Methods: Types: ```python -from cloudflare.types.workers import Domain +from cloudflare.types.workers import ( + DomainUpdateResponse, + DomainListResponse, + DomainDeleteResponse, + DomainGetResponse, +) ``` Methods: -- client.workers.domains.update(\*, account_id, \*\*params) -> Optional[Domain] -- client.workers.domains.list(\*, account_id, \*\*params) -> SyncSinglePage[Domain] -- client.workers.domains.delete(domain_id, \*, account_id) -> None -- client.workers.domains.get(domain_id, \*, account_id) -> Optional[Domain] +- 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 @@ -2672,6 +2716,26 @@ Methods: - 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 @@ -2894,6 +2958,82 @@ Methods: - 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: @@ -2919,6 +3059,30 @@ Methods: - 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: @@ -3528,6 +3692,18 @@ 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: @@ -3593,6 +3769,62 @@ 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 @@ -5617,6 +5849,22 @@ Methods: - 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: @@ -6754,6 +7002,36 @@ 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: @@ -7320,47 +7598,30 @@ Methods: ### Subnets -Types: - -```python -from cloudflare.types.zero_trust.networks import SubnetListResponse -``` - Methods: -- client.zero_trust.networks.subnets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[SubnetListResponse] +- client.zero_trust.networks.subnets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Subnet] #### WARP Types: ```python -from cloudflare.types.zero_trust.networks.subnets import ( - WARPCreateResponse, - WARPDeleteResponse, - WARPEditResponse, - WARPGetResponse, -) +from cloudflare.types.zero_trust.networks.subnets import Subnet, WARPDeleteResponse ``` Methods: -- client.zero_trust.networks.subnets.warp.create(\*, account_id, \*\*params) -> WARPCreateResponse +- 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) -> WARPEditResponse -- client.zero_trust.networks.subnets.warp.get(subnet_id, \*, account_id) -> WARPGetResponse +- 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 -Types: - -```python -from cloudflare.types.zero_trust.networks.subnets import CloudflareSourceUpdateResponse -``` - Methods: -- client.zero_trust.networks.subnets.cloudflare_source.update(address_family, \*, account_id, \*\*params) -> CloudflareSourceUpdateResponse +- client.zero_trust.networks.subnets.cloudflare_source.update(address_family, \*, account_id, \*\*params) -> Subnet ### HostnameRoutes @@ -9303,6 +9564,21 @@ 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: @@ -10424,7 +10700,7 @@ 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) -> InstanceGetResponse +- client.workflows.instances.get(instance_id, \*, account_id, workflow_name, \*\*params) -> InstanceGetResponse ### Status @@ -10521,6 +10797,70 @@ Methods: - 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: @@ -10761,19 +11101,6 @@ Methods: - client.aisearch.instances.search(id, \*, account_id, \*\*params) -> InstanceSearchResponse - client.aisearch.instances.stats(id, \*, account_id) -> InstanceStatsResponse -### Items - -Types: - -```python -from cloudflare.types.aisearch.instances import ItemListResponse, ItemGetResponse -``` - -Methods: - -- client.aisearch.instances.items.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[ItemListResponse] -- client.aisearch.instances.items.get(item_id, \*, account_id, id) -> ItemGetResponse - ### Jobs Types: @@ -10789,7 +11116,7 @@ from cloudflare.types.aisearch.instances import ( Methods: -- client.aisearch.instances.jobs.create(id, \*, account_id) -> JobCreateResponse +- 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 @@ -10959,6 +11286,24 @@ 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 + # CustomPages Types: diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index edc473185de..fddfebb0185 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -99,6 +99,7 @@ security_txt, abuse_reports, email_routing, + email_sending, magic_transit, organizations, secrets_store, @@ -117,12 +118,14 @@ content_scanning, custom_hostnames, resource_sharing, + resource_tagging, token_validation, browser_rendering, mtls_certificates, schema_validation, url_normalization, custom_nameservers, + google_tag_gateway, managed_transforms, client_certificates, custom_certificates, @@ -210,6 +213,7 @@ from .resources.realtime_kit.realtime_kit import RealtimeKitResource, AsyncRealtimeKitResource from .resources.abuse_reports.abuse_reports import AbuseReportsResource, AsyncAbuseReportsResource from .resources.email_routing.email_routing import EmailRoutingResource, AsyncEmailRoutingResource + from .resources.email_sending.email_sending import EmailSendingResource, AsyncEmailSendingResource from .resources.magic_transit.magic_transit import MagicTransitResource, AsyncMagicTransitResource from .resources.organizations.organizations import OrganizationsResource, AsyncOrganizationsResource from .resources.secrets_store.secrets_store import SecretsStoreResource, AsyncSecretsStoreResource @@ -230,10 +234,12 @@ from .resources.content_scanning.content_scanning import ContentScanningResource, AsyncContentScanningResource from .resources.custom_hostnames.custom_hostnames import CustomHostnamesResource, AsyncCustomHostnamesResource from .resources.resource_sharing.resource_sharing import ResourceSharingResource, AsyncResourceSharingResource + from .resources.resource_tagging.resource_tagging import ResourceTaggingResource, AsyncResourceTaggingResource from .resources.token_validation.token_validation import TokenValidationResource, AsyncTokenValidationResource from .resources.browser_rendering.browser_rendering import BrowserRenderingResource, AsyncBrowserRenderingResource from .resources.mtls_certificates.mtls_certificates import MTLSCertificatesResource, AsyncMTLSCertificatesResource from .resources.schema_validation.schema_validation import SchemaValidationResource, AsyncSchemaValidationResource + from .resources.google_tag_gateway.google_tag_gateway import GoogleTagGatewayResource, AsyncGoogleTagGatewayResource from .resources.custom_certificates.custom_certificates import ( CustomCertificatesResource, AsyncCustomCertificatesResource, @@ -483,6 +489,12 @@ def email_routing(self) -> EmailRoutingResource: return EmailRoutingResource(self) + @cached_property + def email_sending(self) -> EmailSendingResource: + from .resources.email_sending import EmailSendingResource + + return EmailSendingResource(self) + @cached_property def filters(self) -> FiltersResource: from .resources.filters import FiltersResource @@ -807,6 +819,12 @@ def origin_post_quantum_encryption(self) -> OriginPostQuantumEncryptionResource: return OriginPostQuantumEncryptionResource(self) + @cached_property + def google_tag_gateway(self) -> GoogleTagGatewayResource: + from .resources.google_tag_gateway import GoogleTagGatewayResource + + return GoogleTagGatewayResource(self) + @cached_property def zaraz(self) -> ZarazResource: from .resources.zaraz import ZarazResource @@ -897,6 +915,12 @@ def resource_sharing(self) -> ResourceSharingResource: return ResourceSharingResource(self) + @cached_property + def resource_tagging(self) -> ResourceTaggingResource: + from .resources.resource_tagging import ResourceTaggingResource + + return ResourceTaggingResource(self) + @cached_property def leaked_credential_checks(self) -> LeakedCredentialChecksResource: from .resources.leaked_credential_checks import LeakedCredentialChecksResource @@ -1349,6 +1373,12 @@ def email_routing(self) -> AsyncEmailRoutingResource: return AsyncEmailRoutingResource(self) + @cached_property + def email_sending(self) -> AsyncEmailSendingResource: + from .resources.email_sending import AsyncEmailSendingResource + + return AsyncEmailSendingResource(self) + @cached_property def filters(self) -> AsyncFiltersResource: from .resources.filters import AsyncFiltersResource @@ -1673,6 +1703,12 @@ def origin_post_quantum_encryption(self) -> AsyncOriginPostQuantumEncryptionReso return AsyncOriginPostQuantumEncryptionResource(self) + @cached_property + def google_tag_gateway(self) -> AsyncGoogleTagGatewayResource: + from .resources.google_tag_gateway import AsyncGoogleTagGatewayResource + + return AsyncGoogleTagGatewayResource(self) + @cached_property def zaraz(self) -> AsyncZarazResource: from .resources.zaraz import AsyncZarazResource @@ -1763,6 +1799,12 @@ def resource_sharing(self) -> AsyncResourceSharingResource: return AsyncResourceSharingResource(self) + @cached_property + def resource_tagging(self) -> AsyncResourceTaggingResource: + from .resources.resource_tagging import AsyncResourceTaggingResource + + return AsyncResourceTaggingResource(self) + @cached_property def leaked_credential_checks(self) -> AsyncLeakedCredentialChecksResource: from .resources.leaked_credential_checks import AsyncLeakedCredentialChecksResource @@ -2143,6 +2185,12 @@ def email_routing(self) -> email_routing.EmailRoutingResourceWithRawResponse: return EmailRoutingResourceWithRawResponse(self._client.email_routing) + @cached_property + def email_sending(self) -> email_sending.EmailSendingResourceWithRawResponse: + from .resources.email_sending import EmailSendingResourceWithRawResponse + + return EmailSendingResourceWithRawResponse(self._client.email_sending) + @cached_property def filters(self) -> filters.FiltersResourceWithRawResponse: from .resources.filters import FiltersResourceWithRawResponse @@ -2469,6 +2517,12 @@ def origin_post_quantum_encryption( return OriginPostQuantumEncryptionResourceWithRawResponse(self._client.origin_post_quantum_encryption) + @cached_property + def google_tag_gateway(self) -> google_tag_gateway.GoogleTagGatewayResourceWithRawResponse: + from .resources.google_tag_gateway import GoogleTagGatewayResourceWithRawResponse + + return GoogleTagGatewayResourceWithRawResponse(self._client.google_tag_gateway) + @cached_property def zaraz(self) -> zaraz.ZarazResourceWithRawResponse: from .resources.zaraz import ZarazResourceWithRawResponse @@ -2559,6 +2613,12 @@ def resource_sharing(self) -> resource_sharing.ResourceSharingResourceWithRawRes return ResourceSharingResourceWithRawResponse(self._client.resource_sharing) + @cached_property + def resource_tagging(self) -> resource_tagging.ResourceTaggingResourceWithRawResponse: + from .resources.resource_tagging import ResourceTaggingResourceWithRawResponse + + return ResourceTaggingResourceWithRawResponse(self._client.resource_tagging) + @cached_property def leaked_credential_checks(self) -> leaked_credential_checks.LeakedCredentialChecksResourceWithRawResponse: from .resources.leaked_credential_checks import LeakedCredentialChecksResourceWithRawResponse @@ -2764,6 +2824,12 @@ def email_routing(self) -> email_routing.AsyncEmailRoutingResourceWithRawRespons return AsyncEmailRoutingResourceWithRawResponse(self._client.email_routing) + @cached_property + def email_sending(self) -> email_sending.AsyncEmailSendingResourceWithRawResponse: + from .resources.email_sending import AsyncEmailSendingResourceWithRawResponse + + return AsyncEmailSendingResourceWithRawResponse(self._client.email_sending) + @cached_property def filters(self) -> filters.AsyncFiltersResourceWithRawResponse: from .resources.filters import AsyncFiltersResourceWithRawResponse @@ -3090,6 +3156,12 @@ def origin_post_quantum_encryption( return AsyncOriginPostQuantumEncryptionResourceWithRawResponse(self._client.origin_post_quantum_encryption) + @cached_property + def google_tag_gateway(self) -> google_tag_gateway.AsyncGoogleTagGatewayResourceWithRawResponse: + from .resources.google_tag_gateway import AsyncGoogleTagGatewayResourceWithRawResponse + + return AsyncGoogleTagGatewayResourceWithRawResponse(self._client.google_tag_gateway) + @cached_property def zaraz(self) -> zaraz.AsyncZarazResourceWithRawResponse: from .resources.zaraz import AsyncZarazResourceWithRawResponse @@ -3180,6 +3252,12 @@ def resource_sharing(self) -> resource_sharing.AsyncResourceSharingResourceWithR return AsyncResourceSharingResourceWithRawResponse(self._client.resource_sharing) + @cached_property + def resource_tagging(self) -> resource_tagging.AsyncResourceTaggingResourceWithRawResponse: + from .resources.resource_tagging import AsyncResourceTaggingResourceWithRawResponse + + return AsyncResourceTaggingResourceWithRawResponse(self._client.resource_tagging) + @cached_property def leaked_credential_checks(self) -> leaked_credential_checks.AsyncLeakedCredentialChecksResourceWithRawResponse: from .resources.leaked_credential_checks import AsyncLeakedCredentialChecksResourceWithRawResponse @@ -3385,6 +3463,12 @@ def email_routing(self) -> email_routing.EmailRoutingResourceWithStreamingRespon return EmailRoutingResourceWithStreamingResponse(self._client.email_routing) + @cached_property + def email_sending(self) -> email_sending.EmailSendingResourceWithStreamingResponse: + from .resources.email_sending import EmailSendingResourceWithStreamingResponse + + return EmailSendingResourceWithStreamingResponse(self._client.email_sending) + @cached_property def filters(self) -> filters.FiltersResourceWithStreamingResponse: from .resources.filters import FiltersResourceWithStreamingResponse @@ -3711,6 +3795,12 @@ def origin_post_quantum_encryption( return OriginPostQuantumEncryptionResourceWithStreamingResponse(self._client.origin_post_quantum_encryption) + @cached_property + def google_tag_gateway(self) -> google_tag_gateway.GoogleTagGatewayResourceWithStreamingResponse: + from .resources.google_tag_gateway import GoogleTagGatewayResourceWithStreamingResponse + + return GoogleTagGatewayResourceWithStreamingResponse(self._client.google_tag_gateway) + @cached_property def zaraz(self) -> zaraz.ZarazResourceWithStreamingResponse: from .resources.zaraz import ZarazResourceWithStreamingResponse @@ -3801,6 +3891,12 @@ def resource_sharing(self) -> resource_sharing.ResourceSharingResourceWithStream return ResourceSharingResourceWithStreamingResponse(self._client.resource_sharing) + @cached_property + def resource_tagging(self) -> resource_tagging.ResourceTaggingResourceWithStreamingResponse: + from .resources.resource_tagging import ResourceTaggingResourceWithStreamingResponse + + return ResourceTaggingResourceWithStreamingResponse(self._client.resource_tagging) + @cached_property def leaked_credential_checks(self) -> leaked_credential_checks.LeakedCredentialChecksResourceWithStreamingResponse: from .resources.leaked_credential_checks import LeakedCredentialChecksResourceWithStreamingResponse @@ -4008,6 +4104,12 @@ def email_routing(self) -> email_routing.AsyncEmailRoutingResourceWithStreamingR return AsyncEmailRoutingResourceWithStreamingResponse(self._client.email_routing) + @cached_property + def email_sending(self) -> email_sending.AsyncEmailSendingResourceWithStreamingResponse: + from .resources.email_sending import AsyncEmailSendingResourceWithStreamingResponse + + return AsyncEmailSendingResourceWithStreamingResponse(self._client.email_sending) + @cached_property def filters(self) -> filters.AsyncFiltersResourceWithStreamingResponse: from .resources.filters import AsyncFiltersResourceWithStreamingResponse @@ -4340,6 +4442,12 @@ def origin_post_quantum_encryption( self._client.origin_post_quantum_encryption ) + @cached_property + def google_tag_gateway(self) -> google_tag_gateway.AsyncGoogleTagGatewayResourceWithStreamingResponse: + from .resources.google_tag_gateway import AsyncGoogleTagGatewayResourceWithStreamingResponse + + return AsyncGoogleTagGatewayResourceWithStreamingResponse(self._client.google_tag_gateway) + @cached_property def zaraz(self) -> zaraz.AsyncZarazResourceWithStreamingResponse: from .resources.zaraz import AsyncZarazResourceWithStreamingResponse @@ -4430,6 +4538,12 @@ def resource_sharing(self) -> resource_sharing.AsyncResourceSharingResourceWithS return AsyncResourceSharingResourceWithStreamingResponse(self._client.resource_sharing) + @cached_property + def resource_tagging(self) -> resource_tagging.AsyncResourceTaggingResourceWithStreamingResponse: + from .resources.resource_tagging import AsyncResourceTaggingResourceWithStreamingResponse + + return AsyncResourceTaggingResourceWithStreamingResponse(self._client.resource_tagging) + @cached_property def leaked_credential_checks( self, diff --git a/src/cloudflare/resources/abuse_reports/abuse_reports.py b/src/cloudflare/resources/abuse_reports/abuse_reports.py index 9cf0a64aa03..0766fbdbf26 100644 --- a/src/cloudflare/resources/abuse_reports/abuse_reports.py +++ b/src/cloudflare/resources/abuse_reports/abuse_reports.py @@ -273,7 +273,7 @@ def create( host_notification: Literal["send", "send-anon"], justification: str, name: str, - owner_notification: Literal["send", "send-anon", "none"], + owner_notification: Literal["send", "send-anon"], urls: str, comments: str | Omit = omit, company: str | Omit = omit, @@ -866,7 +866,7 @@ def create( host_notification: Literal["send"] | Literal["send", "send-anon"] | Omit = omit, name: str, original_work: str | Omit = omit, - owner_notification: Literal["send"] | Literal["send", "send-anon", "none"] | Literal["send", "send-anon"], + owner_notification: Literal["send"] | Literal["send", "send-anon"] | Literal["send", "send-anon", "none"], signature: str | Omit = omit, state: str | Omit = omit, urls: str, @@ -1299,7 +1299,7 @@ async def create( host_notification: Literal["send", "send-anon"], justification: str, name: str, - owner_notification: Literal["send", "send-anon", "none"], + owner_notification: Literal["send", "send-anon"], urls: str, comments: str | Omit = omit, company: str | Omit = omit, @@ -1892,7 +1892,7 @@ async def create( host_notification: Literal["send"] | Literal["send", "send-anon"] | Omit = omit, name: str, original_work: str | Omit = omit, - owner_notification: Literal["send"] | Literal["send", "send-anon", "none"] | Literal["send", "send-anon"], + owner_notification: Literal["send"] | Literal["send", "send-anon"] | Literal["send", "send-anon", "none"], signature: str | Omit = omit, state: str | Omit = omit, urls: str, diff --git a/src/cloudflare/resources/abuse_reports/mitigations.py b/src/cloudflare/resources/abuse_reports/mitigations.py index 298b58d4143..854d18824d2 100644 --- a/src/cloudflare/resources/abuse_reports/mitigations.py +++ b/src/cloudflare/resources/abuse_reports/mitigations.py @@ -70,6 +70,7 @@ def list( status: Literal["pending", "active", "in_review", "cancelled", "removed"] | Omit = omit, type: Literal[ "legal_block", + "misleading_interstitial", "phishing_interstitial", "network_block", "rate_limit_cache", @@ -230,6 +231,7 @@ def list( status: Literal["pending", "active", "in_review", "cancelled", "removed"] | Omit = omit, type: Literal[ "legal_block", + "misleading_interstitial", "phishing_interstitial", "network_block", "rate_limit_cache", diff --git a/src/cloudflare/resources/accounts/logs/audit.py b/src/cloudflare/resources/accounts/logs/audit.py index fd663c7cc68..2eef3ce2f8d 100644 --- a/src/cloudflare/resources/accounts/logs/audit.py +++ b/src/cloudflare/resources/accounts/logs/audit.py @@ -84,13 +84,8 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncCursorPaginationAfter[AuditListResponse]: - """Gets a list of audit logs for an account. - -

This is the beta release - of Audit Logs Version 2. Since this is a beta version, there may be gaps or - missing entries in the available audit logs. Be aware of the following - limitations.
+ """ + Gets a list of audit logs for an account. Args: account_id: The unique id that identifies the account. @@ -226,13 +221,8 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[AuditListResponse, AsyncCursorPaginationAfter[AuditListResponse]]: - """Gets a list of audit logs for an account. - -

This is the beta release - of Audit Logs Version 2. Since this is a beta version, there may be gaps or - missing entries in the available audit logs. Be aware of the following - limitations.
+ """ + Gets a list of audit logs for an account. Args: account_id: The unique id that identifies the account. diff --git a/src/cloudflare/resources/ai/authors.py b/src/cloudflare/resources/ai/authors.py index 8f3ceeb8486..e6b3360823b 100644 --- a/src/cloudflare/resources/ai/authors.py +++ b/src/cloudflare/resources/ai/authors.py @@ -51,7 +51,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[object]: """ - Author Search + Searches Workers AI models by author or organization name. Args: extra_headers: Send extra headers @@ -106,7 +106,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[object, AsyncSinglePage[object]]: """ - Author Search + Searches Workers AI models by author or organization name. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai/finetunes/assets.py b/src/cloudflare/resources/ai/finetunes/assets.py index 50ce6bb6cae..ada060fb7b2 100644 --- a/src/cloudflare/resources/ai/finetunes/assets.py +++ b/src/cloudflare/resources/ai/finetunes/assets.py @@ -58,7 +58,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AssetCreateResponse: """ - Upload a Finetune Asset + Uploads training data assets for a Workers AI fine-tuning job. Args: extra_headers: Send extra headers @@ -130,7 +130,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AssetCreateResponse: """ - Upload a Finetune Asset + Uploads training data assets for a Workers AI fine-tuning job. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai/finetunes/finetunes.py b/src/cloudflare/resources/ai/finetunes/finetunes.py index e998763b6f2..ed583d0a69e 100644 --- a/src/cloudflare/resources/ai/finetunes/finetunes.py +++ b/src/cloudflare/resources/ai/finetunes/finetunes.py @@ -85,7 +85,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> FinetuneCreateResponse: """ - Create a new Finetune + Creates a new fine-tuning job for a Workers AI model using custom training data. Args: extra_headers: Send extra headers @@ -131,7 +131,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> FinetuneListResponse: """ - List Finetunes + Lists all fine-tuning jobs created by the account, including status and metrics. Args: extra_headers: Send extra headers @@ -201,7 +201,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> FinetuneCreateResponse: """ - Create a new Finetune + Creates a new fine-tuning job for a Workers AI model using custom training data. Args: extra_headers: Send extra headers @@ -247,7 +247,7 @@ async def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> FinetuneListResponse: """ - List Finetunes + Lists all fine-tuning jobs created by the account, including status and metrics. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai/finetunes/public.py b/src/cloudflare/resources/ai/finetunes/public.py index 0e8f9e74988..1f519ce3564 100644 --- a/src/cloudflare/resources/ai/finetunes/public.py +++ b/src/cloudflare/resources/ai/finetunes/public.py @@ -57,7 +57,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[PublicListResponse]: """ - List Public Finetunes + Lists publicly available fine-tuned models that can be used with Workers AI. Args: limit: Pagination Limit @@ -132,7 +132,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[PublicListResponse, AsyncSinglePage[PublicListResponse]]: """ - List Public Finetunes + Lists publicly available fine-tuned models that can be used with Workers AI. Args: limit: Pagination Limit diff --git a/src/cloudflare/resources/ai/models/models.py b/src/cloudflare/resources/ai/models/models.py index 9d6d4f9c83d..c2f40e2e160 100644 --- a/src/cloudflare/resources/ai/models/models.py +++ b/src/cloudflare/resources/ai/models/models.py @@ -72,7 +72,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[object]: """ - Model Search + Searches Workers AI models by name or description. Args: author: Filter by Author @@ -163,7 +163,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[object, AsyncV4PagePaginationArray[object]]: """ - Model Search + Searches Workers AI models by name or description. Args: author: Filter by Author diff --git a/src/cloudflare/resources/ai/models/schema.py b/src/cloudflare/resources/ai/models/schema.py index d555ab98627..a041d762955 100644 --- a/src/cloudflare/resources/ai/models/schema.py +++ b/src/cloudflare/resources/ai/models/schema.py @@ -57,7 +57,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaGetResponse: """ - Get Model Schema + Retrieves the input and output JSON schema definition for a Workers AI model. Args: model: Model Name @@ -119,7 +119,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaGetResponse: """ - Get Model Schema + Retrieves the input and output JSON schema definition for a Workers AI model. Args: model: Model Name diff --git a/src/cloudflare/resources/ai/tasks.py b/src/cloudflare/resources/ai/tasks.py index 26fcd51f8b0..a312b56238e 100644 --- a/src/cloudflare/resources/ai/tasks.py +++ b/src/cloudflare/resources/ai/tasks.py @@ -51,7 +51,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[object]: """ - Task Search + Searches Workers AI models by task type (e.g., text-generation, embeddings). Args: extra_headers: Send extra headers @@ -106,7 +106,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[object, AsyncSinglePage[object]]: """ - Task Search + Searches Workers AI models by task type (e.g., text-generation, embeddings). Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai/to_markdown.py b/src/cloudflare/resources/ai/to_markdown.py index 15cab8aa9e4..a4792606100 100644 --- a/src/cloudflare/resources/ai/to_markdown.py +++ b/src/cloudflare/resources/ai/to_markdown.py @@ -57,7 +57,7 @@ def supported( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[ToMarkdownSupportedResponse]: """ - Get all converted formats supported + Lists all file formats supported for conversion to Markdown. Args: extra_headers: Send extra headers @@ -92,7 +92,7 @@ def transform( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[ToMarkdownTransformResponse]: """ - Convert Files into Markdown + Converts uploaded files into Markdown format using Workers AI. Args: extra_headers: Send extra headers @@ -156,7 +156,7 @@ def supported( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ToMarkdownSupportedResponse, AsyncSinglePage[ToMarkdownSupportedResponse]]: """ - Get all converted formats supported + Lists all file formats supported for conversion to Markdown. Args: extra_headers: Send extra headers @@ -191,7 +191,7 @@ def transform( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ToMarkdownTransformResponse, AsyncSinglePage[ToMarkdownTransformResponse]]: """ - Convert Files into Markdown + Converts uploaded files into Markdown format using Workers AI. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 545ad9b28e6..608295f937f 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -144,13 +144,16 @@ def create( collect_logs: bool, rate_limiting_interval: Optional[int], rate_limiting_limit: Optional[int], - rate_limiting_technique: Literal["fixed", "sliding"], authentication: bool | Omit = omit, - is_default: bool | Omit = omit, log_management: Optional[int] | Omit = omit, log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, logpush: bool | Omit = omit, logpush_public_key: Optional[str] | Omit = omit, + rate_limiting_technique: Optional[Literal["fixed", "sliding"]] | Omit = omit, + retry_backoff: Optional[Literal["constant", "linear", "exponential"]] | Omit = omit, + retry_delay: Optional[int] | Omit = omit, + retry_max_attempts: Optional[int] | Omit = omit, + workers_ai_billing_mode: Literal["postpaid"] | Omit = omit, zdr: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -160,11 +163,20 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayCreateResponse: """ - Create a new Gateway + Creates a new AI Gateway. Args: id: gateway id + retry_backoff: Backoff strategy for retry delays + + retry_delay: Delay between retry attempts in milliseconds (0-5000) + + retry_max_attempts: Maximum number of retry attempts for failed requests (1-5) + + workers_ai_billing_mode: Controls how Workers AI inference calls routed through this gateway are billed. + Only 'postpaid' is currently supported. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -185,13 +197,16 @@ def create( "collect_logs": collect_logs, "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, - "rate_limiting_technique": rate_limiting_technique, "authentication": authentication, - "is_default": is_default, "log_management": log_management, "log_management_strategy": log_management_strategy, "logpush": logpush, "logpush_public_key": logpush_public_key, + "rate_limiting_technique": rate_limiting_technique, + "retry_backoff": retry_backoff, + "retry_delay": retry_delay, + "retry_max_attempts": retry_max_attempts, + "workers_ai_billing_mode": workers_ai_billing_mode, "zdr": zdr, }, ai_gateway_create_params.AIGatewayCreateParams, @@ -216,17 +231,20 @@ def update( collect_logs: bool, rate_limiting_interval: Optional[int], rate_limiting_limit: Optional[int], - rate_limiting_technique: Literal["fixed", "sliding"], authentication: bool | Omit = omit, dlp: ai_gateway_update_params.DLP | Omit = omit, - is_default: bool | Omit = omit, log_management: Optional[int] | Omit = omit, log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, logpush: bool | Omit = omit, logpush_public_key: Optional[str] | Omit = omit, otel: Optional[Iterable[ai_gateway_update_params.Otel]] | Omit = omit, + rate_limiting_technique: Optional[Literal["fixed", "sliding"]] | Omit = omit, + retry_backoff: Optional[Literal["constant", "linear", "exponential"]] | Omit = omit, + retry_delay: Optional[int] | Omit = omit, + retry_max_attempts: Optional[int] | Omit = omit, store_id: Optional[str] | Omit = omit, stripe: Optional[ai_gateway_update_params.Stripe] | Omit = omit, + workers_ai_billing_mode: Literal["postpaid"] | Omit = omit, zdr: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -236,11 +254,20 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayUpdateResponse: """ - Update a Gateway + Updates an existing AI Gateway dataset. Args: id: gateway id + retry_backoff: Backoff strategy for retry delays + + retry_delay: Delay between retry attempts in milliseconds (0-5000) + + retry_max_attempts: Maximum number of retry attempts for failed requests (1-5) + + workers_ai_billing_mode: Controls how Workers AI inference calls routed through this gateway are billed. + Only 'postpaid' is currently supported. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -262,17 +289,20 @@ def update( "collect_logs": collect_logs, "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, - "rate_limiting_technique": rate_limiting_technique, "authentication": authentication, "dlp": dlp, - "is_default": is_default, "log_management": log_management, "log_management_strategy": log_management_strategy, "logpush": logpush, "logpush_public_key": logpush_public_key, "otel": otel, + "rate_limiting_technique": rate_limiting_technique, + "retry_backoff": retry_backoff, + "retry_delay": retry_delay, + "retry_max_attempts": retry_max_attempts, "store_id": store_id, "stripe": stripe, + "workers_ai_billing_mode": workers_ai_billing_mode, "zdr": zdr, }, ai_gateway_update_params.AIGatewayUpdateParams, @@ -302,7 +332,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[AIGatewayListResponse]: """ - List Gateways + Lists all AI Gateway evaluator types configured for the account. Args: search: Search by id @@ -350,7 +380,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayDeleteResponse: """ - Delete a Gateway + Deletes an AI Gateway dataset. Args: id: gateway id @@ -392,7 +422,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayGetResponse: """ - Fetch a Gateway + Retrieves details for a specific AI Gateway dataset. Args: id: gateway id @@ -480,13 +510,16 @@ async def create( collect_logs: bool, rate_limiting_interval: Optional[int], rate_limiting_limit: Optional[int], - rate_limiting_technique: Literal["fixed", "sliding"], authentication: bool | Omit = omit, - is_default: bool | Omit = omit, log_management: Optional[int] | Omit = omit, log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, logpush: bool | Omit = omit, logpush_public_key: Optional[str] | Omit = omit, + rate_limiting_technique: Optional[Literal["fixed", "sliding"]] | Omit = omit, + retry_backoff: Optional[Literal["constant", "linear", "exponential"]] | Omit = omit, + retry_delay: Optional[int] | Omit = omit, + retry_max_attempts: Optional[int] | Omit = omit, + workers_ai_billing_mode: Literal["postpaid"] | Omit = omit, zdr: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -496,11 +529,20 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayCreateResponse: """ - Create a new Gateway + Creates a new AI Gateway. Args: id: gateway id + retry_backoff: Backoff strategy for retry delays + + retry_delay: Delay between retry attempts in milliseconds (0-5000) + + retry_max_attempts: Maximum number of retry attempts for failed requests (1-5) + + workers_ai_billing_mode: Controls how Workers AI inference calls routed through this gateway are billed. + Only 'postpaid' is currently supported. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -521,13 +563,16 @@ async def create( "collect_logs": collect_logs, "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, - "rate_limiting_technique": rate_limiting_technique, "authentication": authentication, - "is_default": is_default, "log_management": log_management, "log_management_strategy": log_management_strategy, "logpush": logpush, "logpush_public_key": logpush_public_key, + "rate_limiting_technique": rate_limiting_technique, + "retry_backoff": retry_backoff, + "retry_delay": retry_delay, + "retry_max_attempts": retry_max_attempts, + "workers_ai_billing_mode": workers_ai_billing_mode, "zdr": zdr, }, ai_gateway_create_params.AIGatewayCreateParams, @@ -552,17 +597,20 @@ async def update( collect_logs: bool, rate_limiting_interval: Optional[int], rate_limiting_limit: Optional[int], - rate_limiting_technique: Literal["fixed", "sliding"], authentication: bool | Omit = omit, dlp: ai_gateway_update_params.DLP | Omit = omit, - is_default: bool | Omit = omit, log_management: Optional[int] | Omit = omit, log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, logpush: bool | Omit = omit, logpush_public_key: Optional[str] | Omit = omit, otel: Optional[Iterable[ai_gateway_update_params.Otel]] | Omit = omit, + rate_limiting_technique: Optional[Literal["fixed", "sliding"]] | Omit = omit, + retry_backoff: Optional[Literal["constant", "linear", "exponential"]] | Omit = omit, + retry_delay: Optional[int] | Omit = omit, + retry_max_attempts: Optional[int] | Omit = omit, store_id: Optional[str] | Omit = omit, stripe: Optional[ai_gateway_update_params.Stripe] | Omit = omit, + workers_ai_billing_mode: Literal["postpaid"] | Omit = omit, zdr: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -572,11 +620,20 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayUpdateResponse: """ - Update a Gateway + Updates an existing AI Gateway dataset. Args: id: gateway id + retry_backoff: Backoff strategy for retry delays + + retry_delay: Delay between retry attempts in milliseconds (0-5000) + + retry_max_attempts: Maximum number of retry attempts for failed requests (1-5) + + workers_ai_billing_mode: Controls how Workers AI inference calls routed through this gateway are billed. + Only 'postpaid' is currently supported. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -598,17 +655,20 @@ async def update( "collect_logs": collect_logs, "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, - "rate_limiting_technique": rate_limiting_technique, "authentication": authentication, "dlp": dlp, - "is_default": is_default, "log_management": log_management, "log_management_strategy": log_management_strategy, "logpush": logpush, "logpush_public_key": logpush_public_key, "otel": otel, + "rate_limiting_technique": rate_limiting_technique, + "retry_backoff": retry_backoff, + "retry_delay": retry_delay, + "retry_max_attempts": retry_max_attempts, "store_id": store_id, "stripe": stripe, + "workers_ai_billing_mode": workers_ai_billing_mode, "zdr": zdr, }, ai_gateway_update_params.AIGatewayUpdateParams, @@ -638,7 +698,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[AIGatewayListResponse, AsyncV4PagePaginationArray[AIGatewayListResponse]]: """ - List Gateways + Lists all AI Gateway evaluator types configured for the account. Args: search: Search by id @@ -686,7 +746,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayDeleteResponse: """ - Delete a Gateway + Deletes an AI Gateway dataset. Args: id: gateway id @@ -728,7 +788,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayGetResponse: """ - Fetch a Gateway + Retrieves details for a specific AI Gateway dataset. Args: id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/datasets.py b/src/cloudflare/resources/ai_gateway/datasets.py index bb256a33205..91601b7a385 100644 --- a/src/cloudflare/resources/ai_gateway/datasets.py +++ b/src/cloudflare/resources/ai_gateway/datasets.py @@ -65,7 +65,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetCreateResponse: """ - Create a new Dataset + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -119,7 +119,7 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetUpdateResponse: """ - Update a Dataset + Updates an existing AI Gateway dataset. Args: gateway_id: gateway id @@ -176,7 +176,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[DatasetListResponse]: """ - List Datasets + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -231,7 +231,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetDeleteResponse: """ - Delete a Dataset + Deletes an AI Gateway dataset. Args: gateway_id: gateway id @@ -276,7 +276,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetGetResponse: """ - Fetch a Dataset + Retrieves details for a specific AI Gateway dataset. Args: gateway_id: gateway id @@ -344,7 +344,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetCreateResponse: """ - Create a new Dataset + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -398,7 +398,7 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetUpdateResponse: """ - Update a Dataset + Updates an existing AI Gateway dataset. Args: gateway_id: gateway id @@ -455,7 +455,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[DatasetListResponse, AsyncV4PagePaginationArray[DatasetListResponse]]: """ - List Datasets + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -510,7 +510,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetDeleteResponse: """ - Delete a Dataset + Deletes an AI Gateway dataset. Args: gateway_id: gateway id @@ -555,7 +555,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetGetResponse: """ - Fetch a Dataset + Retrieves details for a specific AI Gateway dataset. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/dynamic_routing.py b/src/cloudflare/resources/ai_gateway/dynamic_routing.py index 719f7e12ff7..d4ad8c97251 100644 --- a/src/cloudflare/resources/ai_gateway/dynamic_routing.py +++ b/src/cloudflare/resources/ai_gateway/dynamic_routing.py @@ -233,7 +233,6 @@ def create_deployment( *, account_id: str, gateway_id: str, - comment: str, version_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -263,10 +262,7 @@ def create_deployment( return self._post( f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", body=maybe_transform( - { - "comment": comment, - "version_id": version_id, - }, + {"version_id": version_id}, dynamic_routing_create_deployment_params.DynamicRoutingCreateDeploymentParams, ), options=make_request_options( @@ -287,7 +283,6 @@ def create_version( *, account_id: str, gateway_id: str, - comment: str, elements: Iterable[dynamic_routing_create_version_params.Element], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -317,11 +312,7 @@ def create_version( return self._post( f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", body=maybe_transform( - { - "comment": comment, - "elements": elements, - }, - dynamic_routing_create_version_params.DynamicRoutingCreateVersionParams, + {"elements": elements}, dynamic_routing_create_version_params.DynamicRoutingCreateVersionParams ), options=make_request_options( extra_headers=extra_headers, @@ -696,7 +687,6 @@ async def create_deployment( *, account_id: str, gateway_id: str, - comment: str, version_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -726,10 +716,7 @@ async def create_deployment( return await self._post( f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", body=await async_maybe_transform( - { - "comment": comment, - "version_id": version_id, - }, + {"version_id": version_id}, dynamic_routing_create_deployment_params.DynamicRoutingCreateDeploymentParams, ), options=make_request_options( @@ -750,7 +737,6 @@ async def create_version( *, account_id: str, gateway_id: str, - comment: str, elements: Iterable[dynamic_routing_create_version_params.Element], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -780,11 +766,7 @@ async def create_version( return await self._post( f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", body=await async_maybe_transform( - { - "comment": comment, - "elements": elements, - }, - dynamic_routing_create_version_params.DynamicRoutingCreateVersionParams, + {"elements": elements}, dynamic_routing_create_version_params.DynamicRoutingCreateVersionParams ), 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 e3d9fd87309..b466e084495 100644 --- a/src/cloudflare/resources/ai_gateway/evaluations.py +++ b/src/cloudflare/resources/ai_gateway/evaluations.py @@ -64,7 +64,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationCreateResponse: """ - Create a new Evaluation + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -119,7 +119,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[EvaluationListResponse]: """ - List Evaluations + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -174,7 +174,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationDeleteResponse: """ - Delete a Evaluation + Deletes an AI Gateway dataset. Args: gateway_id: gateway id @@ -219,7 +219,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationGetResponse: """ - Fetch a Evaluation + Retrieves details for a specific AI Gateway dataset. Args: gateway_id: gateway id @@ -287,7 +287,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationCreateResponse: """ - Create a new Evaluation + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -342,7 +342,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[EvaluationListResponse, AsyncV4PagePaginationArray[EvaluationListResponse]]: """ - List Evaluations + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -397,7 +397,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationDeleteResponse: """ - Delete a Evaluation + Deletes an AI Gateway dataset. Args: gateway_id: gateway id @@ -442,7 +442,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationGetResponse: """ - Fetch a Evaluation + Retrieves details for a specific AI Gateway dataset. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py index 8518d36781c..0ea6559c96b 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -236,7 +236,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Patch Gateway Log + Updates metadata for an AI Gateway log entry. Args: gateway_id: gateway id @@ -289,7 +289,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> LogGetResponse: """ - Get Gateway Log Detail + Retrieves detailed information for a specific AI Gateway log entry. Args: gateway_id: gateway id @@ -334,7 +334,7 @@ def request( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Get Gateway Log Request + Retrieves the original request payload for an AI Gateway log entry. Args: gateway_id: gateway id @@ -375,7 +375,7 @@ def response( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Get Gateway Log Response + Retrieves the response payload for an AI Gateway log entry. Args: gateway_id: gateway id @@ -610,7 +610,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Patch Gateway Log + Updates metadata for an AI Gateway log entry. Args: gateway_id: gateway id @@ -663,7 +663,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> LogGetResponse: """ - Get Gateway Log Detail + Retrieves detailed information for a specific AI Gateway log entry. Args: gateway_id: gateway id @@ -708,7 +708,7 @@ async def request( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Get Gateway Log Request + Retrieves the original request payload for an AI Gateway log entry. Args: gateway_id: gateway id @@ -749,7 +749,7 @@ async def response( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Get Gateway Log Response + Retrieves the response payload for an AI Gateway log entry. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/provider_configs.py b/src/cloudflare/resources/ai_gateway/provider_configs.py index 60c7fc5f891..2e75c14bdc3 100644 --- a/src/cloudflare/resources/ai_gateway/provider_configs.py +++ b/src/cloudflare/resources/ai_gateway/provider_configs.py @@ -66,7 +66,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ProviderConfigCreateResponse: """ - Create a new Provider Configs + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -122,7 +122,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[ProviderConfigListResponse]: """ - List Provider Configs + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -199,7 +199,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ProviderConfigCreateResponse: """ - Create a new Provider Configs + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -255,7 +255,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ProviderConfigListResponse, AsyncV4PagePaginationArray[ProviderConfigListResponse]]: """ - List Provider Configs + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/urls.py b/src/cloudflare/resources/ai_gateway/urls.py index 8f660faa164..988e21ecc24 100644 --- a/src/cloudflare/resources/ai_gateway/urls.py +++ b/src/cloudflare/resources/ai_gateway/urls.py @@ -56,7 +56,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: """ - Get Gateway URL + Retrieves the endpoint URL for an AI Gateway. Args: gateway_id: gateway id @@ -122,7 +122,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: """ - Get Gateway URL + Retrieves the endpoint URL for an AI Gateway. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/aisearch/instances/__init__.py b/src/cloudflare/resources/aisearch/instances/__init__.py index bcd3fe82f43..f07262e470e 100644 --- a/src/cloudflare/resources/aisearch/instances/__init__.py +++ b/src/cloudflare/resources/aisearch/instances/__init__.py @@ -8,14 +8,6 @@ JobsResourceWithStreamingResponse, AsyncJobsResourceWithStreamingResponse, ) -from .items import ( - ItemsResource, - AsyncItemsResource, - ItemsResourceWithRawResponse, - AsyncItemsResourceWithRawResponse, - ItemsResourceWithStreamingResponse, - AsyncItemsResourceWithStreamingResponse, -) from .instances import ( InstancesResource, AsyncInstancesResource, @@ -26,12 +18,6 @@ ) __all__ = [ - "ItemsResource", - "AsyncItemsResource", - "ItemsResourceWithRawResponse", - "AsyncItemsResourceWithRawResponse", - "ItemsResourceWithStreamingResponse", - "AsyncItemsResourceWithStreamingResponse", "JobsResource", "AsyncJobsResource", "JobsResourceWithRawResponse", diff --git a/src/cloudflare/resources/aisearch/instances/instances.py b/src/cloudflare/resources/aisearch/instances/instances.py index 256d55b0ba3..40435a59ec1 100644 --- a/src/cloudflare/resources/aisearch/instances/instances.py +++ b/src/cloudflare/resources/aisearch/instances/instances.py @@ -15,14 +15,6 @@ JobsResourceWithStreamingResponse, AsyncJobsResourceWithStreamingResponse, ) -from .items import ( - ItemsResource, - AsyncItemsResource, - ItemsResourceWithRawResponse, - AsyncItemsResourceWithRawResponse, - ItemsResourceWithStreamingResponse, - AsyncItemsResourceWithStreamingResponse, -) from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property @@ -56,10 +48,6 @@ class InstancesResource(SyncAPIResource): - @cached_property - def items(self) -> ItemsResource: - return ItemsResource(self._client) - @cached_property def jobs(self) -> JobsResource: return JobsResource(self._client) @@ -88,98 +76,109 @@ def create( *, account_id: str, id: str, - source: str, - type: Literal["r2", "web-crawler"], ai_gateway_id: Optional[str] | Omit = omit, - aisearch_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", - "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", - "", + 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", + "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: Literal[ - "@cf/qwen/qwen3-embedding-0.6b", - "@cf/baai/bge-m3", - "@cf/baai/bge-large-en-v1.5", - "@cf/google/embeddinggemma-300m", - "google-ai-studio/gemini-embedding-001", - "openai/text-embedding-3-small", - "openai/text-embedding-3-large", - "", + 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, + 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: Literal["@cf/baai/bge-reranker-base", ""] | Omit = omit, + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] | Omit = omit, retrieval_options: Optional[instance_create_params.RetrievalOptions] | Omit = omit, - rewrite_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", - "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_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", + "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: str | Omit = omit, source_params: Optional[instance_create_params.SourceParams] | Omit = omit, token_id: str | Omit = omit, + type: 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, @@ -187,11 +186,12 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceCreateResponse: - """ - Create a new instances. + """Create a new instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -208,10 +208,10 @@ def create( body=maybe_transform( { "id": id, - "source": source, - "type": type, "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, @@ -219,6 +219,7 @@ def create( "embedding_model": embedding_model, "fusion_method": fusion_method, "hybrid_search_enabled": hybrid_search_enabled, + "indexing_options": indexing_options, "max_num_results": max_num_results, "metadata": metadata, "public_endpoint_params": public_endpoint_params, @@ -228,8 +229,10 @@ def create( "rewrite_model": rewrite_model, "rewrite_query": rewrite_query, "score_threshold": score_threshold, + "source": source, "source_params": source_params, "token_id": token_id, + "type": type, }, instance_create_params.InstanceCreateParams, ), @@ -249,35 +252,37 @@ def update( *, account_id: str, ai_gateway_id: Optional[str] | Omit = omit, - aisearch_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", - "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", - "", + 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", + "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, @@ -287,90 +292,98 @@ def update( chunk_overlap: int | Omit = omit, chunk_size: int | Omit = omit, custom_metadata: Iterable[instance_update_params.CustomMetadata] | Omit = omit, - embedding_model: Literal[ - "@cf/qwen/qwen3-embedding-0.6b", - "@cf/baai/bge-m3", - "@cf/baai/bge-large-en-v1.5", - "@cf/google/embeddinggemma-300m", - "google-ai-studio/gemini-embedding-001", - "openai/text-embedding-3-small", - "openai/text-embedding-3-large", - "", + 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, + 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: Literal["@cf/baai/bge-reranker-base", ""] | Omit = omit, + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] | Omit = omit, retrieval_options: Optional[instance_update_params.RetrievalOptions] | Omit = omit, - rewrite_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", - "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_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", + "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: 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", - "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", - "", + 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", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] ] | Omit = omit, system_prompt_aisearch: Optional[str] | Omit = omit, @@ -384,11 +397,12 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceUpdateResponse: - """ - Update instances. + """Update instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -417,6 +431,7 @@ def update( "embedding_model": embedding_model, "fusion_method": fusion_method, "hybrid_search_enabled": hybrid_search_enabled, + "indexing_options": indexing_options, "max_num_results": max_num_results, "metadata": metadata, "paused": paused, @@ -451,6 +466,9 @@ def list( self, *, account_id: str, + 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, @@ -465,6 +483,10 @@ def list( List instances. Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + search: Search by id extra_headers: Send extra headers @@ -487,6 +509,9 @@ def list( 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, @@ -509,11 +534,12 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceDeleteResponse: - """ - Delete instances. + """Delete instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -590,7 +616,7 @@ def chat_completions( content as context for generating responses. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -633,11 +659,12 @@ def read( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceReadResponse: - """ - Read instances. + """Read instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -682,7 +709,7 @@ def search( indexed content. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -731,7 +758,7 @@ def stats( Retrieves usage statistics for AI Search instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -759,10 +786,6 @@ def stats( class AsyncInstancesResource(AsyncAPIResource): - @cached_property - def items(self) -> AsyncItemsResource: - return AsyncItemsResource(self._client) - @cached_property def jobs(self) -> AsyncJobsResource: return AsyncJobsResource(self._client) @@ -791,98 +814,109 @@ async def create( *, account_id: str, id: str, - source: str, - type: Literal["r2", "web-crawler"], ai_gateway_id: Optional[str] | Omit = omit, - aisearch_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", - "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", - "", + 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", + "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: Literal[ - "@cf/qwen/qwen3-embedding-0.6b", - "@cf/baai/bge-m3", - "@cf/baai/bge-large-en-v1.5", - "@cf/google/embeddinggemma-300m", - "google-ai-studio/gemini-embedding-001", - "openai/text-embedding-3-small", - "openai/text-embedding-3-large", - "", + 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, + 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: Literal["@cf/baai/bge-reranker-base", ""] | Omit = omit, + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] | Omit = omit, retrieval_options: Optional[instance_create_params.RetrievalOptions] | Omit = omit, - rewrite_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", - "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_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", + "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: str | Omit = omit, source_params: Optional[instance_create_params.SourceParams] | Omit = omit, token_id: str | Omit = omit, + type: 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, @@ -890,11 +924,12 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceCreateResponse: - """ - Create a new instances. + """Create a new instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -911,10 +946,10 @@ async def create( body=await async_maybe_transform( { "id": id, - "source": source, - "type": type, "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, @@ -922,6 +957,7 @@ async def create( "embedding_model": embedding_model, "fusion_method": fusion_method, "hybrid_search_enabled": hybrid_search_enabled, + "indexing_options": indexing_options, "max_num_results": max_num_results, "metadata": metadata, "public_endpoint_params": public_endpoint_params, @@ -931,8 +967,10 @@ async def create( "rewrite_model": rewrite_model, "rewrite_query": rewrite_query, "score_threshold": score_threshold, + "source": source, "source_params": source_params, "token_id": token_id, + "type": type, }, instance_create_params.InstanceCreateParams, ), @@ -952,35 +990,37 @@ async def update( *, account_id: str, ai_gateway_id: Optional[str] | Omit = omit, - aisearch_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", - "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", - "", + 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", + "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, @@ -990,90 +1030,98 @@ async def update( chunk_overlap: int | Omit = omit, chunk_size: int | Omit = omit, custom_metadata: Iterable[instance_update_params.CustomMetadata] | Omit = omit, - embedding_model: Literal[ - "@cf/qwen/qwen3-embedding-0.6b", - "@cf/baai/bge-m3", - "@cf/baai/bge-large-en-v1.5", - "@cf/google/embeddinggemma-300m", - "google-ai-studio/gemini-embedding-001", - "openai/text-embedding-3-small", - "openai/text-embedding-3-large", - "", + 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, + 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: Literal["@cf/baai/bge-reranker-base", ""] | Omit = omit, + reranking_model: Optional[Literal["@cf/baai/bge-reranker-base", ""]] | Omit = omit, retrieval_options: Optional[instance_update_params.RetrievalOptions] | Omit = omit, - rewrite_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", - "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_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", + "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: 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", - "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", - "", + 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", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] ] | Omit = omit, system_prompt_aisearch: Optional[str] | Omit = omit, @@ -1087,11 +1135,12 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceUpdateResponse: - """ - Update instances. + """Update instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -1120,6 +1169,7 @@ async def update( "embedding_model": embedding_model, "fusion_method": fusion_method, "hybrid_search_enabled": hybrid_search_enabled, + "indexing_options": indexing_options, "max_num_results": max_num_results, "metadata": metadata, "paused": paused, @@ -1154,6 +1204,9 @@ def list( self, *, account_id: str, + 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, @@ -1168,6 +1221,10 @@ def list( List instances. Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + search: Search by id extra_headers: Send extra headers @@ -1190,6 +1247,9 @@ def list( 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, @@ -1212,11 +1272,12 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceDeleteResponse: - """ - Delete instances. + """Delete instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -1293,7 +1354,7 @@ async def chat_completions( content as context for generating responses. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -1336,11 +1397,12 @@ async def read( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceReadResponse: - """ - Read instances. + """Read instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. + + Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -1385,7 +1447,7 @@ async def search( indexed content. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -1434,7 +1496,7 @@ async def stats( Retrieves usage statistics for AI Search instances. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -1490,10 +1552,6 @@ def __init__(self, instances: InstancesResource) -> None: instances.stats, ) - @cached_property - def items(self) -> ItemsResourceWithRawResponse: - return ItemsResourceWithRawResponse(self._instances.items) - @cached_property def jobs(self) -> JobsResourceWithRawResponse: return JobsResourceWithRawResponse(self._instances.jobs) @@ -1528,10 +1586,6 @@ def __init__(self, instances: AsyncInstancesResource) -> None: instances.stats, ) - @cached_property - def items(self) -> AsyncItemsResourceWithRawResponse: - return AsyncItemsResourceWithRawResponse(self._instances.items) - @cached_property def jobs(self) -> AsyncJobsResourceWithRawResponse: return AsyncJobsResourceWithRawResponse(self._instances.jobs) @@ -1566,10 +1620,6 @@ def __init__(self, instances: InstancesResource) -> None: instances.stats, ) - @cached_property - def items(self) -> ItemsResourceWithStreamingResponse: - return ItemsResourceWithStreamingResponse(self._instances.items) - @cached_property def jobs(self) -> JobsResourceWithStreamingResponse: return JobsResourceWithStreamingResponse(self._instances.jobs) @@ -1604,10 +1654,6 @@ def __init__(self, instances: AsyncInstancesResource) -> None: instances.stats, ) - @cached_property - def items(self) -> AsyncItemsResourceWithStreamingResponse: - return AsyncItemsResourceWithStreamingResponse(self._instances.items) - @cached_property def jobs(self) -> AsyncJobsResourceWithStreamingResponse: return AsyncJobsResourceWithStreamingResponse(self._instances.jobs) diff --git a/src/cloudflare/resources/aisearch/instances/items.py b/src/cloudflare/resources/aisearch/instances/items.py deleted file mode 100644 index eaa492c2593..00000000000 --- a/src/cloudflare/resources/aisearch/instances/items.py +++ /dev/null @@ -1,317 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, cast -from typing_extensions import Literal - -import httpx - -from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from ...._utils import maybe_transform -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ...._wrappers import ResultWrapper -from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ...._base_client import AsyncPaginator, make_request_options -from ....types.aisearch.instances import item_list_params -from ....types.aisearch.instances.item_get_response import ItemGetResponse -from ....types.aisearch.instances.item_list_response import ItemListResponse - -__all__ = ["ItemsResource", "AsyncItemsResource"] - - -class ItemsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> ItemsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return ItemsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> ItemsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return ItemsResourceWithStreamingResponse(self) - - def list( - self, - id: str, - *, - account_id: str, - page: int | Omit = omit, - per_page: int | Omit = omit, - search: str | Omit = omit, - status: Literal["queued", "running", "completed", "error", "skipped"] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncV4PagePaginationArray[ItemListResponse]: - """ - Lists indexed items in an AI Search instance. - - Args: - id: Use your AI Search ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get_api_list( - f"/accounts/{account_id}/ai-search/instances/{id}/items", - page=SyncV4PagePaginationArray[ItemListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - "search": search, - "status": status, - }, - item_list_params.ItemListParams, - ), - ), - model=ItemListResponse, - ) - - def get( - self, - item_id: str, - *, - account_id: str, - id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ItemGetResponse: - """ - Retrieves a specific indexed item from an AI Search instance. - - Args: - id: Use your AI Search ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - if not item_id: - raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}") - return self._get( - f"/accounts/{account_id}/ai-search/instances/{id}/items/{item_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ItemGetResponse]._unwrapper, - ), - cast_to=cast(Type[ItemGetResponse], ResultWrapper[ItemGetResponse]), - ) - - -class AsyncItemsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncItemsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncItemsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncItemsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncItemsResourceWithStreamingResponse(self) - - def list( - self, - id: str, - *, - account_id: str, - page: int | Omit = omit, - per_page: int | Omit = omit, - search: str | Omit = omit, - status: Literal["queued", "running", "completed", "error", "skipped"] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[ItemListResponse, AsyncV4PagePaginationArray[ItemListResponse]]: - """ - Lists indexed items in an AI Search instance. - - Args: - id: Use your AI Search ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get_api_list( - f"/accounts/{account_id}/ai-search/instances/{id}/items", - page=AsyncV4PagePaginationArray[ItemListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - "search": search, - "status": status, - }, - item_list_params.ItemListParams, - ), - ), - model=ItemListResponse, - ) - - async def get( - self, - item_id: str, - *, - account_id: str, - id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ItemGetResponse: - """ - Retrieves a specific indexed item from an AI Search instance. - - Args: - id: Use your AI Search ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - if not item_id: - raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}") - return await self._get( - f"/accounts/{account_id}/ai-search/instances/{id}/items/{item_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ItemGetResponse]._unwrapper, - ), - cast_to=cast(Type[ItemGetResponse], ResultWrapper[ItemGetResponse]), - ) - - -class ItemsResourceWithRawResponse: - def __init__(self, items: ItemsResource) -> None: - self._items = items - - self.list = to_raw_response_wrapper( - items.list, - ) - self.get = to_raw_response_wrapper( - items.get, - ) - - -class AsyncItemsResourceWithRawResponse: - def __init__(self, items: AsyncItemsResource) -> None: - self._items = items - - self.list = async_to_raw_response_wrapper( - items.list, - ) - self.get = async_to_raw_response_wrapper( - items.get, - ) - - -class ItemsResourceWithStreamingResponse: - def __init__(self, items: ItemsResource) -> None: - self._items = items - - self.list = to_streamed_response_wrapper( - items.list, - ) - self.get = to_streamed_response_wrapper( - items.get, - ) - - -class AsyncItemsResourceWithStreamingResponse: - def __init__(self, items: AsyncItemsResource) -> None: - self._items = items - - self.list = async_to_streamed_response_wrapper( - items.list, - ) - self.get = async_to_streamed_response_wrapper( - items.get, - ) diff --git a/src/cloudflare/resources/aisearch/instances/jobs.py b/src/cloudflare/resources/aisearch/instances/jobs.py index d5c03bf6e7a..a9bfcf9eb60 100644 --- a/src/cloudflare/resources/aisearch/instances/jobs.py +++ b/src/cloudflare/resources/aisearch/instances/jobs.py @@ -19,7 +19,7 @@ from ...._wrappers import ResultWrapper from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ...._base_client import AsyncPaginator, make_request_options -from ....types.aisearch.instances import job_list_params, job_logs_params +from ....types.aisearch.instances import job_list_params, job_logs_params, job_create_params from ....types.aisearch.instances.job_get_response import JobGetResponse from ....types.aisearch.instances.job_list_response import JobListResponse from ....types.aisearch.instances.job_logs_response import JobLogsResponse @@ -53,6 +53,7 @@ def create( id: str, *, account_id: 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, @@ -64,7 +65,7 @@ def create( Creates a new indexing job for an AI Search instance. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -80,6 +81,7 @@ def create( 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", + body=maybe_transform({"description": description}, job_create_params.JobCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -108,7 +110,7 @@ def list( Lists indexing jobs for an AI Search instance. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -158,7 +160,7 @@ def get( Retrieves details for a specific AI Search indexing job. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -205,7 +207,7 @@ def logs( Lists log entries for an AI Search indexing job. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -266,6 +268,7 @@ async def create( id: str, *, account_id: 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, @@ -277,7 +280,7 @@ async def create( Creates a new indexing job for an AI Search instance. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -293,6 +296,7 @@ async def create( 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", + body=await async_maybe_transform({"description": description}, job_create_params.JobCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -321,7 +325,7 @@ def list( Lists indexing jobs for an AI Search instance. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -371,7 +375,7 @@ async def get( Retrieves details for a specific AI Search indexing job. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers @@ -418,7 +422,7 @@ async def logs( Lists log entries for an AI Search indexing job. Args: - id: Use your AI Search ID. + id: AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/aisearch/tokens.py b/src/cloudflare/resources/aisearch/tokens.py index 8916dfecec0..94654a58c85 100644 --- a/src/cloudflare/resources/aisearch/tokens.py +++ b/src/cloudflare/resources/aisearch/tokens.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Type, cast +from typing_extensions import Literal import httpx @@ -152,6 +153,8 @@ def list( self, *, account_id: str, + order_by: Literal["created_at"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -165,6 +168,10 @@ def list( List tokens. Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -185,6 +192,8 @@ def list( timeout=timeout, query=maybe_transform( { + "order_by": order_by, + "order_by_direction": order_by_direction, "page": page, "per_page": per_page, }, @@ -398,6 +407,8 @@ def list( self, *, account_id: str, + order_by: Literal["created_at"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -411,6 +422,10 @@ def list( List tokens. Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -431,6 +446,8 @@ def list( timeout=timeout, query=maybe_transform( { + "order_by": order_by, + "order_by_direction": order_by_direction, "page": page, "per_page": per_page, }, diff --git a/src/cloudflare/resources/api_gateway/__init__.py b/src/cloudflare/resources/api_gateway/__init__.py index c93926a6412..2b6b0d96ed3 100644 --- a/src/cloudflare/resources/api_gateway/__init__.py +++ b/src/cloudflare/resources/api_gateway/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .labels import ( + LabelsResource, + AsyncLabelsResource, + LabelsResourceWithRawResponse, + AsyncLabelsResourceWithRawResponse, + LabelsResourceWithStreamingResponse, + AsyncLabelsResourceWithStreamingResponse, +) from .schemas import ( SchemasResource, AsyncSchemasResource, @@ -78,6 +86,12 @@ "AsyncDiscoveryResourceWithRawResponse", "DiscoveryResourceWithStreamingResponse", "AsyncDiscoveryResourceWithStreamingResponse", + "LabelsResource", + "AsyncLabelsResource", + "LabelsResourceWithRawResponse", + "AsyncLabelsResourceWithRawResponse", + "LabelsResourceWithStreamingResponse", + "AsyncLabelsResourceWithStreamingResponse", "OperationsResource", "AsyncOperationsResource", "OperationsResourceWithRawResponse", diff --git a/src/cloudflare/resources/api_gateway/api_gateway.py b/src/cloudflare/resources/api_gateway/api_gateway.py index 70917610f7d..5da73ba77b0 100644 --- a/src/cloudflare/resources/api_gateway/api_gateway.py +++ b/src/cloudflare/resources/api_gateway/api_gateway.py @@ -12,6 +12,14 @@ ) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource +from .labels.labels import ( + LabelsResource, + AsyncLabelsResource, + LabelsResourceWithRawResponse, + AsyncLabelsResourceWithRawResponse, + LabelsResourceWithStreamingResponse, + AsyncLabelsResourceWithStreamingResponse, +) from .configurations import ( ConfigurationsResource, AsyncConfigurationsResource, @@ -73,6 +81,10 @@ def configurations(self) -> ConfigurationsResource: def discovery(self) -> DiscoveryResource: return DiscoveryResource(self._client) + @cached_property + def labels(self) -> LabelsResource: + return LabelsResource(self._client) + @cached_property def operations(self) -> OperationsResource: return OperationsResource(self._client) @@ -122,6 +134,10 @@ def configurations(self) -> AsyncConfigurationsResource: def discovery(self) -> AsyncDiscoveryResource: return AsyncDiscoveryResource(self._client) + @cached_property + def labels(self) -> AsyncLabelsResource: + return AsyncLabelsResource(self._client) + @cached_property def operations(self) -> AsyncOperationsResource: return AsyncOperationsResource(self._client) @@ -174,6 +190,10 @@ def configurations(self) -> ConfigurationsResourceWithRawResponse: def discovery(self) -> DiscoveryResourceWithRawResponse: return DiscoveryResourceWithRawResponse(self._api_gateway.discovery) + @cached_property + def labels(self) -> LabelsResourceWithRawResponse: + return LabelsResourceWithRawResponse(self._api_gateway.labels) + @cached_property def operations(self) -> OperationsResourceWithRawResponse: return OperationsResourceWithRawResponse(self._api_gateway.operations) @@ -207,6 +227,10 @@ def configurations(self) -> AsyncConfigurationsResourceWithRawResponse: def discovery(self) -> AsyncDiscoveryResourceWithRawResponse: return AsyncDiscoveryResourceWithRawResponse(self._api_gateway.discovery) + @cached_property + def labels(self) -> AsyncLabelsResourceWithRawResponse: + return AsyncLabelsResourceWithRawResponse(self._api_gateway.labels) + @cached_property def operations(self) -> AsyncOperationsResourceWithRawResponse: return AsyncOperationsResourceWithRawResponse(self._api_gateway.operations) @@ -240,6 +264,10 @@ def configurations(self) -> ConfigurationsResourceWithStreamingResponse: def discovery(self) -> DiscoveryResourceWithStreamingResponse: return DiscoveryResourceWithStreamingResponse(self._api_gateway.discovery) + @cached_property + def labels(self) -> LabelsResourceWithStreamingResponse: + return LabelsResourceWithStreamingResponse(self._api_gateway.labels) + @cached_property def operations(self) -> OperationsResourceWithStreamingResponse: return OperationsResourceWithStreamingResponse(self._api_gateway.operations) @@ -273,6 +301,10 @@ def configurations(self) -> AsyncConfigurationsResourceWithStreamingResponse: def discovery(self) -> AsyncDiscoveryResourceWithStreamingResponse: return AsyncDiscoveryResourceWithStreamingResponse(self._api_gateway.discovery) + @cached_property + def labels(self) -> AsyncLabelsResourceWithStreamingResponse: + return AsyncLabelsResourceWithStreamingResponse(self._api_gateway.labels) + @cached_property def operations(self) -> AsyncOperationsResourceWithStreamingResponse: return AsyncOperationsResourceWithStreamingResponse(self._api_gateway.operations) diff --git a/src/cloudflare/resources/api_gateway/configurations.py b/src/cloudflare/resources/api_gateway/configurations.py index 96cebe13223..bd62e5e568b 100644 --- a/src/cloudflare/resources/api_gateway/configurations.py +++ b/src/cloudflare/resources/api_gateway/configurations.py @@ -57,8 +57,10 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: - """ - Update configuration properties + """Updates API Shield configuration settings for a zone. + + Can modify validation + strictness, enforcement mode, and other global settings. Args: zone_id: Identifier. @@ -105,7 +107,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: """ - Retrieve information about specific configuration properties + Gets the current API Shield configuration settings for a zone, including + validation behavior and enforcement mode. Args: zone_id: Identifier. @@ -169,8 +172,10 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: - """ - Update configuration properties + """Updates API Shield configuration settings for a zone. + + Can modify validation + strictness, enforcement mode, and other global settings. Args: zone_id: Identifier. @@ -219,7 +224,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: """ - Retrieve information about specific configuration properties + Gets the current API Shield configuration settings for a zone, including + validation behavior and enforcement mode. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py b/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py index 1434470cfad..8f4d2735cd0 100644 --- a/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py +++ b/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py @@ -56,8 +56,10 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> FallthroughCreateResponse: - """ - Generate fallthrough WAF expression template from a set of API hosts + """Creates an expression template fallthrough rule for API Shield. + + Used for + configuring default behavior when no other expression templates match. Args: zone_id: Identifier. @@ -120,8 +122,10 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> FallthroughCreateResponse: - """ - Generate fallthrough WAF expression template from a set of API hosts + """Creates an expression template fallthrough rule for API Shield. + + Used for + configuring default behavior when no other expression templates match. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/api_gateway/labels/__init__.py b/src/cloudflare/resources/api_gateway/labels/__init__.py new file mode 100644 index 00000000000..95f9b9debcd --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .user import ( + UserResource, + AsyncUserResource, + UserResourceWithRawResponse, + AsyncUserResourceWithRawResponse, + UserResourceWithStreamingResponse, + AsyncUserResourceWithStreamingResponse, +) +from .labels import ( + LabelsResource, + AsyncLabelsResource, + LabelsResourceWithRawResponse, + AsyncLabelsResourceWithRawResponse, + LabelsResourceWithStreamingResponse, + AsyncLabelsResourceWithStreamingResponse, +) +from .managed import ( + ManagedResource, + AsyncManagedResource, + ManagedResourceWithRawResponse, + AsyncManagedResourceWithRawResponse, + ManagedResourceWithStreamingResponse, + AsyncManagedResourceWithStreamingResponse, +) + +__all__ = [ + "UserResource", + "AsyncUserResource", + "UserResourceWithRawResponse", + "AsyncUserResourceWithRawResponse", + "UserResourceWithStreamingResponse", + "AsyncUserResourceWithStreamingResponse", + "ManagedResource", + "AsyncManagedResource", + "ManagedResourceWithRawResponse", + "AsyncManagedResourceWithRawResponse", + "ManagedResourceWithStreamingResponse", + "AsyncManagedResourceWithStreamingResponse", + "LabelsResource", + "AsyncLabelsResource", + "LabelsResourceWithRawResponse", + "AsyncLabelsResourceWithRawResponse", + "LabelsResourceWithStreamingResponse", + "AsyncLabelsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/labels/labels.py b/src/cloudflare/resources/api_gateway/labels/labels.py new file mode 100644 index 00000000000..4f2280b9c56 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/labels.py @@ -0,0 +1,312 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform +from .user.user import ( + UserResource, + AsyncUserResource, + UserResourceWithRawResponse, + AsyncUserResourceWithRawResponse, + UserResourceWithStreamingResponse, + AsyncUserResourceWithStreamingResponse, +) +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 .managed.managed import ( + ManagedResource, + AsyncManagedResource, + ManagedResourceWithRawResponse, + AsyncManagedResourceWithRawResponse, + ManagedResourceWithStreamingResponse, + AsyncManagedResourceWithStreamingResponse, +) +from ....types.api_gateway import label_list_params +from ....types.api_gateway.label_list_response import LabelListResponse + +__all__ = ["LabelsResource", "AsyncLabelsResource"] + + +class LabelsResource(SyncAPIResource): + @cached_property + def user(self) -> UserResource: + return UserResource(self._client) + + @cached_property + def managed(self) -> ManagedResource: + return ManagedResource(self._client) + + @cached_property + def with_raw_response(self) -> LabelsResourceWithRawResponse: + """ + 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 LabelsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LabelsResourceWithStreamingResponse: + """ + 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 LabelsResourceWithStreamingResponse(self) + + def list( + self, + *, + zone_id: str, + direction: Literal["asc", "desc"] | Omit = omit, + filter: str | Omit = omit, + order: Literal["name", "description", "created_at", "last_updated", "mapped_resources.operations"] + | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + source: Literal["user", "managed"] | Omit = omit, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[LabelListResponse]: + """ + Retrieve all labels + + Args: + zone_id: Identifier. + + direction: Direction to order results. + + filter: Filter for labels where the name or description matches using substring match + + order: Field to order by + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + source: Filter for labels with source + + with_mapped_resource_counts: Include `mapped_resources` for each label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/labels", + page=SyncV4PagePaginationArray[LabelListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "filter": filter, + "order": order, + "page": page, + "per_page": per_page, + "source": source, + "with_mapped_resource_counts": with_mapped_resource_counts, + }, + label_list_params.LabelListParams, + ), + ), + model=LabelListResponse, + ) + + +class AsyncLabelsResource(AsyncAPIResource): + @cached_property + def user(self) -> AsyncUserResource: + return AsyncUserResource(self._client) + + @cached_property + def managed(self) -> AsyncManagedResource: + return AsyncManagedResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncLabelsResourceWithRawResponse: + """ + 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 AsyncLabelsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLabelsResourceWithStreamingResponse: + """ + 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 AsyncLabelsResourceWithStreamingResponse(self) + + def list( + self, + *, + zone_id: str, + direction: Literal["asc", "desc"] | Omit = omit, + filter: str | Omit = omit, + order: Literal["name", "description", "created_at", "last_updated", "mapped_resources.operations"] + | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + source: Literal["user", "managed"] | Omit = omit, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[LabelListResponse, AsyncV4PagePaginationArray[LabelListResponse]]: + """ + Retrieve all labels + + Args: + zone_id: Identifier. + + direction: Direction to order results. + + filter: Filter for labels where the name or description matches using substring match + + order: Field to order by + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + source: Filter for labels with source + + with_mapped_resource_counts: Include `mapped_resources` for each label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/labels", + page=AsyncV4PagePaginationArray[LabelListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "filter": filter, + "order": order, + "page": page, + "per_page": per_page, + "source": source, + "with_mapped_resource_counts": with_mapped_resource_counts, + }, + label_list_params.LabelListParams, + ), + ), + model=LabelListResponse, + ) + + +class LabelsResourceWithRawResponse: + def __init__(self, labels: LabelsResource) -> None: + self._labels = labels + + self.list = to_raw_response_wrapper( + labels.list, + ) + + @cached_property + def user(self) -> UserResourceWithRawResponse: + return UserResourceWithRawResponse(self._labels.user) + + @cached_property + def managed(self) -> ManagedResourceWithRawResponse: + return ManagedResourceWithRawResponse(self._labels.managed) + + +class AsyncLabelsResourceWithRawResponse: + def __init__(self, labels: AsyncLabelsResource) -> None: + self._labels = labels + + self.list = async_to_raw_response_wrapper( + labels.list, + ) + + @cached_property + def user(self) -> AsyncUserResourceWithRawResponse: + return AsyncUserResourceWithRawResponse(self._labels.user) + + @cached_property + def managed(self) -> AsyncManagedResourceWithRawResponse: + return AsyncManagedResourceWithRawResponse(self._labels.managed) + + +class LabelsResourceWithStreamingResponse: + def __init__(self, labels: LabelsResource) -> None: + self._labels = labels + + self.list = to_streamed_response_wrapper( + labels.list, + ) + + @cached_property + def user(self) -> UserResourceWithStreamingResponse: + return UserResourceWithStreamingResponse(self._labels.user) + + @cached_property + def managed(self) -> ManagedResourceWithStreamingResponse: + return ManagedResourceWithStreamingResponse(self._labels.managed) + + +class AsyncLabelsResourceWithStreamingResponse: + def __init__(self, labels: AsyncLabelsResource) -> None: + self._labels = labels + + self.list = async_to_streamed_response_wrapper( + labels.list, + ) + + @cached_property + def user(self) -> AsyncUserResourceWithStreamingResponse: + return AsyncUserResourceWithStreamingResponse(self._labels.user) + + @cached_property + def managed(self) -> AsyncManagedResourceWithStreamingResponse: + return AsyncManagedResourceWithStreamingResponse(self._labels.managed) diff --git a/src/cloudflare/resources/api_gateway/labels/managed/__init__.py b/src/cloudflare/resources/api_gateway/labels/managed/__init__.py new file mode 100644 index 00000000000..5bd9c6fa3b7 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/managed/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .managed import ( + ManagedResource, + AsyncManagedResource, + ManagedResourceWithRawResponse, + AsyncManagedResourceWithRawResponse, + ManagedResourceWithStreamingResponse, + AsyncManagedResourceWithStreamingResponse, +) +from .resources import ( + ResourcesResource, + AsyncResourcesResource, + ResourcesResourceWithRawResponse, + AsyncResourcesResourceWithRawResponse, + ResourcesResourceWithStreamingResponse, + AsyncResourcesResourceWithStreamingResponse, +) + +__all__ = [ + "ResourcesResource", + "AsyncResourcesResource", + "ResourcesResourceWithRawResponse", + "AsyncResourcesResourceWithRawResponse", + "ResourcesResourceWithStreamingResponse", + "AsyncResourcesResourceWithStreamingResponse", + "ManagedResource", + "AsyncManagedResource", + "ManagedResourceWithRawResponse", + "AsyncManagedResourceWithRawResponse", + "ManagedResourceWithStreamingResponse", + "AsyncManagedResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/labels/managed/managed.py b/src/cloudflare/resources/api_gateway/labels/managed/managed.py new file mode 100644 index 00000000000..fef15b370e5 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/managed/managed.py @@ -0,0 +1,234 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import make_request_options +from .resources.resources import ( + ResourcesResource, + AsyncResourcesResource, + ResourcesResourceWithRawResponse, + AsyncResourcesResourceWithRawResponse, + ResourcesResourceWithStreamingResponse, + AsyncResourcesResourceWithStreamingResponse, +) +from .....types.api_gateway.labels import managed_get_params +from .....types.api_gateway.labels.managed_get_response import ManagedGetResponse + +__all__ = ["ManagedResource", "AsyncManagedResource"] + + +class ManagedResource(SyncAPIResource): + @cached_property + def resources(self) -> ResourcesResource: + return ResourcesResource(self._client) + + @cached_property + def with_raw_response(self) -> ManagedResourceWithRawResponse: + """ + 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 ManagedResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ManagedResourceWithStreamingResponse: + """ + 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 ManagedResourceWithStreamingResponse(self) + + def get( + self, + name: str, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ManagedGetResponse: + """ + Retrieve managed label + + Args: + zone_id: Identifier. + + name: The name of the label + + with_mapped_resource_counts: Include `mapped_resources` for each label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + {"with_mapped_resource_counts": with_mapped_resource_counts}, managed_get_params.ManagedGetParams + ), + post_parser=ResultWrapper[ManagedGetResponse]._unwrapper, + ), + cast_to=cast(Type[ManagedGetResponse], ResultWrapper[ManagedGetResponse]), + ) + + +class AsyncManagedResource(AsyncAPIResource): + @cached_property + def resources(self) -> AsyncResourcesResource: + return AsyncResourcesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncManagedResourceWithRawResponse: + """ + 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 AsyncManagedResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncManagedResourceWithStreamingResponse: + """ + 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 AsyncManagedResourceWithStreamingResponse(self) + + async def get( + self, + name: str, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ManagedGetResponse: + """ + Retrieve managed label + + Args: + zone_id: Identifier. + + name: The name of the label + + with_mapped_resource_counts: Include `mapped_resources` for each label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"with_mapped_resource_counts": with_mapped_resource_counts}, managed_get_params.ManagedGetParams + ), + post_parser=ResultWrapper[ManagedGetResponse]._unwrapper, + ), + cast_to=cast(Type[ManagedGetResponse], ResultWrapper[ManagedGetResponse]), + ) + + +class ManagedResourceWithRawResponse: + def __init__(self, managed: ManagedResource) -> None: + self._managed = managed + + self.get = to_raw_response_wrapper( + managed.get, + ) + + @cached_property + def resources(self) -> ResourcesResourceWithRawResponse: + return ResourcesResourceWithRawResponse(self._managed.resources) + + +class AsyncManagedResourceWithRawResponse: + def __init__(self, managed: AsyncManagedResource) -> None: + self._managed = managed + + self.get = async_to_raw_response_wrapper( + managed.get, + ) + + @cached_property + def resources(self) -> AsyncResourcesResourceWithRawResponse: + return AsyncResourcesResourceWithRawResponse(self._managed.resources) + + +class ManagedResourceWithStreamingResponse: + def __init__(self, managed: ManagedResource) -> None: + self._managed = managed + + self.get = to_streamed_response_wrapper( + managed.get, + ) + + @cached_property + def resources(self) -> ResourcesResourceWithStreamingResponse: + return ResourcesResourceWithStreamingResponse(self._managed.resources) + + +class AsyncManagedResourceWithStreamingResponse: + def __init__(self, managed: AsyncManagedResource) -> None: + self._managed = managed + + self.get = async_to_streamed_response_wrapper( + managed.get, + ) + + @cached_property + def resources(self) -> AsyncResourcesResourceWithStreamingResponse: + return AsyncResourcesResourceWithStreamingResponse(self._managed.resources) diff --git a/src/cloudflare/resources/api_gateway/labels/managed/resources/__init__.py b/src/cloudflare/resources/api_gateway/labels/managed/resources/__init__.py new file mode 100644 index 00000000000..b30c92d0f74 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/managed/resources/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .operation import ( + OperationResource, + AsyncOperationResource, + OperationResourceWithRawResponse, + AsyncOperationResourceWithRawResponse, + OperationResourceWithStreamingResponse, + AsyncOperationResourceWithStreamingResponse, +) +from .resources import ( + ResourcesResource, + AsyncResourcesResource, + ResourcesResourceWithRawResponse, + AsyncResourcesResourceWithRawResponse, + ResourcesResourceWithStreamingResponse, + AsyncResourcesResourceWithStreamingResponse, +) + +__all__ = [ + "OperationResource", + "AsyncOperationResource", + "OperationResourceWithRawResponse", + "AsyncOperationResourceWithRawResponse", + "OperationResourceWithStreamingResponse", + "AsyncOperationResourceWithStreamingResponse", + "ResourcesResource", + "AsyncResourcesResource", + "ResourcesResourceWithRawResponse", + "AsyncResourcesResourceWithRawResponse", + "ResourcesResourceWithStreamingResponse", + "AsyncResourcesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/labels/managed/resources/operation.py b/src/cloudflare/resources/api_gateway/labels/managed/resources/operation.py new file mode 100644 index 00000000000..edf21582d99 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/managed/resources/operation.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ......_types import Body, Query, Headers, NotGiven, not_given +from ......_utils import maybe_transform, async_maybe_transform +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.api_gateway.labels.managed.resources import operation_update_params +from ......types.api_gateway.labels.managed.resources.operation_update_response import OperationUpdateResponse + +__all__ = ["OperationResource", "AsyncOperationResource"] + + +class OperationResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OperationResourceWithRawResponse: + """ + 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 OperationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OperationResourceWithStreamingResponse: + """ + 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 OperationResourceWithStreamingResponse(self) + + def update( + self, + name: str, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OperationUpdateResponse: + """ + Replace all operations(s) attached to a managed label + + Args: + zone_id: Identifier. + + name: The name of the label + + selector: Operation IDs selector + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + body=maybe_transform({"selector": selector}, operation_update_params.OperationUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[OperationUpdateResponse], ResultWrapper[OperationUpdateResponse]), + ) + + +class AsyncOperationResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOperationResourceWithRawResponse: + """ + 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 AsyncOperationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOperationResourceWithStreamingResponse: + """ + 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 AsyncOperationResourceWithStreamingResponse(self) + + async def update( + self, + name: str, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OperationUpdateResponse: + """ + Replace all operations(s) attached to a managed label + + Args: + zone_id: Identifier. + + name: The name of the label + + selector: Operation IDs selector + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + body=await async_maybe_transform({"selector": selector}, operation_update_params.OperationUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[OperationUpdateResponse], ResultWrapper[OperationUpdateResponse]), + ) + + +class OperationResourceWithRawResponse: + def __init__(self, operation: OperationResource) -> None: + self._operation = operation + + self.update = to_raw_response_wrapper( + operation.update, + ) + + +class AsyncOperationResourceWithRawResponse: + def __init__(self, operation: AsyncOperationResource) -> None: + self._operation = operation + + self.update = async_to_raw_response_wrapper( + operation.update, + ) + + +class OperationResourceWithStreamingResponse: + def __init__(self, operation: OperationResource) -> None: + self._operation = operation + + self.update = to_streamed_response_wrapper( + operation.update, + ) + + +class AsyncOperationResourceWithStreamingResponse: + def __init__(self, operation: AsyncOperationResource) -> None: + self._operation = operation + + self.update = async_to_streamed_response_wrapper( + operation.update, + ) diff --git a/src/cloudflare/resources/api_gateway/labels/managed/resources/resources.py b/src/cloudflare/resources/api_gateway/labels/managed/resources/resources.py new file mode 100644 index 00000000000..5db031c863d --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/managed/resources/resources.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .operation import ( + OperationResource, + AsyncOperationResource, + OperationResourceWithRawResponse, + AsyncOperationResourceWithRawResponse, + OperationResourceWithStreamingResponse, + AsyncOperationResourceWithStreamingResponse, +) +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["ResourcesResource", "AsyncResourcesResource"] + + +class ResourcesResource(SyncAPIResource): + @cached_property + def operation(self) -> OperationResource: + return OperationResource(self._client) + + @cached_property + def with_raw_response(self) -> ResourcesResourceWithRawResponse: + """ + 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 ResourcesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ResourcesResourceWithStreamingResponse: + """ + 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 ResourcesResourceWithStreamingResponse(self) + + +class AsyncResourcesResource(AsyncAPIResource): + @cached_property + def operation(self) -> AsyncOperationResource: + return AsyncOperationResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncResourcesResourceWithRawResponse: + """ + 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 AsyncResourcesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncResourcesResourceWithStreamingResponse: + """ + 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 AsyncResourcesResourceWithStreamingResponse(self) + + +class ResourcesResourceWithRawResponse: + def __init__(self, resources: ResourcesResource) -> None: + self._resources = resources + + @cached_property + def operation(self) -> OperationResourceWithRawResponse: + return OperationResourceWithRawResponse(self._resources.operation) + + +class AsyncResourcesResourceWithRawResponse: + def __init__(self, resources: AsyncResourcesResource) -> None: + self._resources = resources + + @cached_property + def operation(self) -> AsyncOperationResourceWithRawResponse: + return AsyncOperationResourceWithRawResponse(self._resources.operation) + + +class ResourcesResourceWithStreamingResponse: + def __init__(self, resources: ResourcesResource) -> None: + self._resources = resources + + @cached_property + def operation(self) -> OperationResourceWithStreamingResponse: + return OperationResourceWithStreamingResponse(self._resources.operation) + + +class AsyncResourcesResourceWithStreamingResponse: + def __init__(self, resources: AsyncResourcesResource) -> None: + self._resources = resources + + @cached_property + def operation(self) -> AsyncOperationResourceWithStreamingResponse: + return AsyncOperationResourceWithStreamingResponse(self._resources.operation) diff --git a/src/cloudflare/resources/api_gateway/labels/user/__init__.py b/src/cloudflare/resources/api_gateway/labels/user/__init__.py new file mode 100644 index 00000000000..16d4f7dce35 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/user/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .user import ( + UserResource, + AsyncUserResource, + UserResourceWithRawResponse, + AsyncUserResourceWithRawResponse, + UserResourceWithStreamingResponse, + AsyncUserResourceWithStreamingResponse, +) +from .resources import ( + ResourcesResource, + AsyncResourcesResource, + ResourcesResourceWithRawResponse, + AsyncResourcesResourceWithRawResponse, + ResourcesResourceWithStreamingResponse, + AsyncResourcesResourceWithStreamingResponse, +) + +__all__ = [ + "ResourcesResource", + "AsyncResourcesResource", + "ResourcesResourceWithRawResponse", + "AsyncResourcesResourceWithRawResponse", + "ResourcesResourceWithStreamingResponse", + "AsyncResourcesResourceWithStreamingResponse", + "UserResource", + "AsyncUserResource", + "UserResourceWithRawResponse", + "AsyncUserResourceWithRawResponse", + "UserResourceWithStreamingResponse", + "AsyncUserResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/labels/user/resources/__init__.py b/src/cloudflare/resources/api_gateway/labels/user/resources/__init__.py new file mode 100644 index 00000000000..b30c92d0f74 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/user/resources/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .operation import ( + OperationResource, + AsyncOperationResource, + OperationResourceWithRawResponse, + AsyncOperationResourceWithRawResponse, + OperationResourceWithStreamingResponse, + AsyncOperationResourceWithStreamingResponse, +) +from .resources import ( + ResourcesResource, + AsyncResourcesResource, + ResourcesResourceWithRawResponse, + AsyncResourcesResourceWithRawResponse, + ResourcesResourceWithStreamingResponse, + AsyncResourcesResourceWithStreamingResponse, +) + +__all__ = [ + "OperationResource", + "AsyncOperationResource", + "OperationResourceWithRawResponse", + "AsyncOperationResourceWithRawResponse", + "OperationResourceWithStreamingResponse", + "AsyncOperationResourceWithStreamingResponse", + "ResourcesResource", + "AsyncResourcesResource", + "ResourcesResourceWithRawResponse", + "AsyncResourcesResourceWithRawResponse", + "ResourcesResourceWithStreamingResponse", + "AsyncResourcesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/labels/user/resources/operation.py b/src/cloudflare/resources/api_gateway/labels/user/resources/operation.py new file mode 100644 index 00000000000..57532ca8f3a --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/user/resources/operation.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ......_types import Body, Query, Headers, NotGiven, not_given +from ......_utils import maybe_transform, async_maybe_transform +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.api_gateway.labels.user.resources import operation_update_params +from ......types.api_gateway.labels.user.resources.operation_update_response import OperationUpdateResponse + +__all__ = ["OperationResource", "AsyncOperationResource"] + + +class OperationResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OperationResourceWithRawResponse: + """ + 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 OperationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OperationResourceWithStreamingResponse: + """ + 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 OperationResourceWithStreamingResponse(self) + + def update( + self, + name: str, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OperationUpdateResponse: + """ + Replace all operations(s) attached to a user label + + Args: + zone_id: Identifier. + + name: The name of the label + + selector: Operation IDs selector + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + body=maybe_transform({"selector": selector}, operation_update_params.OperationUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[OperationUpdateResponse], ResultWrapper[OperationUpdateResponse]), + ) + + +class AsyncOperationResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOperationResourceWithRawResponse: + """ + 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 AsyncOperationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOperationResourceWithStreamingResponse: + """ + 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 AsyncOperationResourceWithStreamingResponse(self) + + async def update( + self, + name: str, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OperationUpdateResponse: + """ + Replace all operations(s) attached to a user label + + Args: + zone_id: Identifier. + + name: The name of the label + + selector: Operation IDs selector + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + body=await async_maybe_transform({"selector": selector}, operation_update_params.OperationUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[OperationUpdateResponse], ResultWrapper[OperationUpdateResponse]), + ) + + +class OperationResourceWithRawResponse: + def __init__(self, operation: OperationResource) -> None: + self._operation = operation + + self.update = to_raw_response_wrapper( + operation.update, + ) + + +class AsyncOperationResourceWithRawResponse: + def __init__(self, operation: AsyncOperationResource) -> None: + self._operation = operation + + self.update = async_to_raw_response_wrapper( + operation.update, + ) + + +class OperationResourceWithStreamingResponse: + def __init__(self, operation: OperationResource) -> None: + self._operation = operation + + self.update = to_streamed_response_wrapper( + operation.update, + ) + + +class AsyncOperationResourceWithStreamingResponse: + def __init__(self, operation: AsyncOperationResource) -> None: + self._operation = operation + + self.update = async_to_streamed_response_wrapper( + operation.update, + ) diff --git a/src/cloudflare/resources/api_gateway/labels/user/resources/resources.py b/src/cloudflare/resources/api_gateway/labels/user/resources/resources.py new file mode 100644 index 00000000000..5db031c863d --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/user/resources/resources.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .operation import ( + OperationResource, + AsyncOperationResource, + OperationResourceWithRawResponse, + AsyncOperationResourceWithRawResponse, + OperationResourceWithStreamingResponse, + AsyncOperationResourceWithStreamingResponse, +) +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["ResourcesResource", "AsyncResourcesResource"] + + +class ResourcesResource(SyncAPIResource): + @cached_property + def operation(self) -> OperationResource: + return OperationResource(self._client) + + @cached_property + def with_raw_response(self) -> ResourcesResourceWithRawResponse: + """ + 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 ResourcesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ResourcesResourceWithStreamingResponse: + """ + 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 ResourcesResourceWithStreamingResponse(self) + + +class AsyncResourcesResource(AsyncAPIResource): + @cached_property + def operation(self) -> AsyncOperationResource: + return AsyncOperationResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncResourcesResourceWithRawResponse: + """ + 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 AsyncResourcesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncResourcesResourceWithStreamingResponse: + """ + 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 AsyncResourcesResourceWithStreamingResponse(self) + + +class ResourcesResourceWithRawResponse: + def __init__(self, resources: ResourcesResource) -> None: + self._resources = resources + + @cached_property + def operation(self) -> OperationResourceWithRawResponse: + return OperationResourceWithRawResponse(self._resources.operation) + + +class AsyncResourcesResourceWithRawResponse: + def __init__(self, resources: AsyncResourcesResource) -> None: + self._resources = resources + + @cached_property + def operation(self) -> AsyncOperationResourceWithRawResponse: + return AsyncOperationResourceWithRawResponse(self._resources.operation) + + +class ResourcesResourceWithStreamingResponse: + def __init__(self, resources: ResourcesResource) -> None: + self._resources = resources + + @cached_property + def operation(self) -> OperationResourceWithStreamingResponse: + return OperationResourceWithStreamingResponse(self._resources.operation) + + +class AsyncResourcesResourceWithStreamingResponse: + def __init__(self, resources: AsyncResourcesResource) -> None: + self._resources = resources + + @cached_property + def operation(self) -> AsyncOperationResourceWithStreamingResponse: + return AsyncOperationResourceWithStreamingResponse(self._resources.operation) diff --git a/src/cloudflare/resources/api_gateway/labels/user/user.py b/src/cloudflare/resources/api_gateway/labels/user/user.py new file mode 100644 index 00000000000..ee4a303db37 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/labels/user/user.py @@ -0,0 +1,768 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, cast + +import httpx + +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from .....pagination import SyncSinglePage, AsyncSinglePage +from ....._base_client import AsyncPaginator, make_request_options +from .resources.resources import ( + ResourcesResource, + AsyncResourcesResource, + ResourcesResourceWithRawResponse, + AsyncResourcesResourceWithRawResponse, + ResourcesResourceWithStreamingResponse, + AsyncResourcesResourceWithStreamingResponse, +) +from .....types.api_gateway.labels import user_get_params, user_edit_params, user_update_params, user_bulk_create_params +from .....types.api_gateway.labels.user_get_response import UserGetResponse +from .....types.api_gateway.labels.user_edit_response import UserEditResponse +from .....types.api_gateway.labels.user_delete_response import UserDeleteResponse +from .....types.api_gateway.labels.user_update_response import UserUpdateResponse +from .....types.api_gateway.labels.user_bulk_create_response import UserBulkCreateResponse +from .....types.api_gateway.labels.user_bulk_delete_response import UserBulkDeleteResponse + +__all__ = ["UserResource", "AsyncUserResource"] + + +class UserResource(SyncAPIResource): + @cached_property + def resources(self) -> ResourcesResource: + return ResourcesResource(self._client) + + @cached_property + def with_raw_response(self) -> UserResourceWithRawResponse: + """ + 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 UserResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> UserResourceWithStreamingResponse: + """ + 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 UserResourceWithStreamingResponse(self) + + def update( + self, + name: str, + *, + zone_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserUpdateResponse: + """ + Update all fields on a label + + Args: + zone_id: Identifier. + + name: The name of the label + + description: The description of the label + + metadata: Metadata for the label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + body=maybe_transform( + { + "description": description, + "metadata": metadata, + }, + user_update_params.UserUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[UserUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[UserUpdateResponse], ResultWrapper[UserUpdateResponse]), + ) + + def delete( + self, + name: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserDeleteResponse: + """ + Delete user label + + Args: + zone_id: Identifier. + + name: The name of the label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[UserDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[UserDeleteResponse], ResultWrapper[UserDeleteResponse]), + ) + + def bulk_create( + self, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[UserBulkCreateResponse]: + """ + Create user labels + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/labels/user", + page=SyncSinglePage[UserBulkCreateResponse], + body=maybe_transform(body, Iterable[user_bulk_create_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=UserBulkCreateResponse, + method="post", + ) + + def bulk_delete( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[UserBulkDeleteResponse]: + """ + Delete user labels + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/labels/user", + page=SyncSinglePage[UserBulkDeleteResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=UserBulkDeleteResponse, + method="delete", + ) + + def edit( + self, + name: str, + *, + zone_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserEditResponse: + """ + Update certain fields on a label + + Args: + zone_id: Identifier. + + name: The name of the label + + description: The description of the label + + metadata: Metadata for the label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + body=maybe_transform( + { + "description": description, + "metadata": metadata, + }, + user_edit_params.UserEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[UserEditResponse]._unwrapper, + ), + cast_to=cast(Type[UserEditResponse], ResultWrapper[UserEditResponse]), + ) + + def get( + self, + name: str, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserGetResponse: + """ + Retrieve user label + + Args: + zone_id: Identifier. + + name: The name of the label + + with_mapped_resource_counts: Include `mapped_resources` for each label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + {"with_mapped_resource_counts": with_mapped_resource_counts}, user_get_params.UserGetParams + ), + post_parser=ResultWrapper[UserGetResponse]._unwrapper, + ), + cast_to=cast(Type[UserGetResponse], ResultWrapper[UserGetResponse]), + ) + + +class AsyncUserResource(AsyncAPIResource): + @cached_property + def resources(self) -> AsyncResourcesResource: + return AsyncResourcesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncUserResourceWithRawResponse: + """ + 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 AsyncUserResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncUserResourceWithStreamingResponse: + """ + 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 AsyncUserResourceWithStreamingResponse(self) + + async def update( + self, + name: str, + *, + zone_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserUpdateResponse: + """ + Update all fields on a label + + Args: + zone_id: Identifier. + + name: The name of the label + + description: The description of the label + + metadata: Metadata for the label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + body=await async_maybe_transform( + { + "description": description, + "metadata": metadata, + }, + user_update_params.UserUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[UserUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[UserUpdateResponse], ResultWrapper[UserUpdateResponse]), + ) + + async def delete( + self, + name: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserDeleteResponse: + """ + Delete user label + + Args: + zone_id: Identifier. + + name: The name of the label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[UserDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[UserDeleteResponse], ResultWrapper[UserDeleteResponse]), + ) + + def bulk_create( + self, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[UserBulkCreateResponse, AsyncSinglePage[UserBulkCreateResponse]]: + """ + Create user labels + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/labels/user", + page=AsyncSinglePage[UserBulkCreateResponse], + body=maybe_transform(body, Iterable[user_bulk_create_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=UserBulkCreateResponse, + method="post", + ) + + def bulk_delete( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[UserBulkDeleteResponse, AsyncSinglePage[UserBulkDeleteResponse]]: + """ + Delete user labels + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/labels/user", + page=AsyncSinglePage[UserBulkDeleteResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=UserBulkDeleteResponse, + method="delete", + ) + + async def edit( + self, + name: str, + *, + zone_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserEditResponse: + """ + Update certain fields on a label + + Args: + zone_id: Identifier. + + name: The name of the label + + description: The description of the label + + metadata: Metadata for the label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + body=await async_maybe_transform( + { + "description": description, + "metadata": metadata, + }, + user_edit_params.UserEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[UserEditResponse]._unwrapper, + ), + cast_to=cast(Type[UserEditResponse], ResultWrapper[UserEditResponse]), + ) + + async def get( + self, + name: str, + *, + zone_id: str, + 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserGetResponse: + """ + Retrieve user label + + Args: + zone_id: Identifier. + + name: The name of the label + + with_mapped_resource_counts: Include `mapped_resources` for each label + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"with_mapped_resource_counts": with_mapped_resource_counts}, user_get_params.UserGetParams + ), + post_parser=ResultWrapper[UserGetResponse]._unwrapper, + ), + cast_to=cast(Type[UserGetResponse], ResultWrapper[UserGetResponse]), + ) + + +class UserResourceWithRawResponse: + def __init__(self, user: UserResource) -> None: + self._user = user + + self.update = to_raw_response_wrapper( + user.update, + ) + self.delete = to_raw_response_wrapper( + user.delete, + ) + self.bulk_create = to_raw_response_wrapper( + user.bulk_create, + ) + self.bulk_delete = to_raw_response_wrapper( + user.bulk_delete, + ) + self.edit = to_raw_response_wrapper( + user.edit, + ) + self.get = to_raw_response_wrapper( + user.get, + ) + + @cached_property + def resources(self) -> ResourcesResourceWithRawResponse: + return ResourcesResourceWithRawResponse(self._user.resources) + + +class AsyncUserResourceWithRawResponse: + def __init__(self, user: AsyncUserResource) -> None: + self._user = user + + self.update = async_to_raw_response_wrapper( + user.update, + ) + self.delete = async_to_raw_response_wrapper( + user.delete, + ) + self.bulk_create = async_to_raw_response_wrapper( + user.bulk_create, + ) + self.bulk_delete = async_to_raw_response_wrapper( + user.bulk_delete, + ) + self.edit = async_to_raw_response_wrapper( + user.edit, + ) + self.get = async_to_raw_response_wrapper( + user.get, + ) + + @cached_property + def resources(self) -> AsyncResourcesResourceWithRawResponse: + return AsyncResourcesResourceWithRawResponse(self._user.resources) + + +class UserResourceWithStreamingResponse: + def __init__(self, user: UserResource) -> None: + self._user = user + + self.update = to_streamed_response_wrapper( + user.update, + ) + self.delete = to_streamed_response_wrapper( + user.delete, + ) + self.bulk_create = to_streamed_response_wrapper( + user.bulk_create, + ) + self.bulk_delete = to_streamed_response_wrapper( + user.bulk_delete, + ) + self.edit = to_streamed_response_wrapper( + user.edit, + ) + self.get = to_streamed_response_wrapper( + user.get, + ) + + @cached_property + def resources(self) -> ResourcesResourceWithStreamingResponse: + return ResourcesResourceWithStreamingResponse(self._user.resources) + + +class AsyncUserResourceWithStreamingResponse: + def __init__(self, user: AsyncUserResource) -> None: + self._user = user + + self.update = async_to_streamed_response_wrapper( + user.update, + ) + self.delete = async_to_streamed_response_wrapper( + user.delete, + ) + self.bulk_create = async_to_streamed_response_wrapper( + user.bulk_create, + ) + self.bulk_delete = async_to_streamed_response_wrapper( + user.bulk_delete, + ) + self.edit = async_to_streamed_response_wrapper( + user.edit, + ) + self.get = async_to_streamed_response_wrapper( + user.get, + ) + + @cached_property + def resources(self) -> AsyncResourcesResourceWithStreamingResponse: + return AsyncResourcesResourceWithStreamingResponse(self._user.resources) diff --git a/src/cloudflare/resources/api_gateway/operations/__init__.py b/src/cloudflare/resources/api_gateway/operations/__init__.py index d50a9df3f11..158055f28a9 100644 --- a/src/cloudflare/resources/api_gateway/operations/__init__.py +++ b/src/cloudflare/resources/api_gateway/operations/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .labels import ( + LabelsResource, + AsyncLabelsResource, + LabelsResourceWithRawResponse, + AsyncLabelsResourceWithRawResponse, + LabelsResourceWithStreamingResponse, + AsyncLabelsResourceWithStreamingResponse, +) from .operations import ( OperationsResource, AsyncOperationsResource, @@ -18,6 +26,12 @@ ) __all__ = [ + "LabelsResource", + "AsyncLabelsResource", + "LabelsResourceWithRawResponse", + "AsyncLabelsResourceWithRawResponse", + "LabelsResourceWithStreamingResponse", + "AsyncLabelsResourceWithStreamingResponse", "SchemaValidationResource", "AsyncSchemaValidationResource", "SchemaValidationResourceWithRawResponse", diff --git a/src/cloudflare/resources/api_gateway/operations/labels.py b/src/cloudflare/resources/api_gateway/operations/labels.py new file mode 100644 index 00000000000..8ad2bb6e87c --- /dev/null +++ b/src/cloudflare/resources/api_gateway/operations/labels.py @@ -0,0 +1,775 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import AsyncPaginator, make_request_options +from ....types.api_gateway.operations import ( + label_create_params, + label_update_params, + label_bulk_create_params, + label_bulk_update_params, +) +from ....types.api_gateway.operations.label_create_response import LabelCreateResponse +from ....types.api_gateway.operations.label_delete_response import LabelDeleteResponse +from ....types.api_gateway.operations.label_update_response import LabelUpdateResponse +from ....types.api_gateway.operations.label_bulk_create_response import LabelBulkCreateResponse +from ....types.api_gateway.operations.label_bulk_delete_response import LabelBulkDeleteResponse +from ....types.api_gateway.operations.label_bulk_update_response import LabelBulkUpdateResponse + +__all__ = ["LabelsResource", "AsyncLabelsResource"] + + +class LabelsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> LabelsResourceWithRawResponse: + """ + 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 LabelsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LabelsResourceWithStreamingResponse: + """ + 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 LabelsResourceWithStreamingResponse(self) + + def create( + self, + operation_id: str, + *, + zone_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LabelCreateResponse: + """ + Attach label(s) on an operation in endpoint management + + Args: + zone_id: Identifier. + + operation_id: UUID. + + managed: List of managed label names. + + user: List of user label names. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + body=maybe_transform( + { + "managed": managed, + "user": user, + }, + label_create_params.LabelCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LabelCreateResponse]._unwrapper, + ), + cast_to=cast(Type[LabelCreateResponse], ResultWrapper[LabelCreateResponse]), + ) + + def update( + self, + operation_id: str, + *, + zone_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LabelUpdateResponse: + """ + Replace label(s) on an operation in endpoint management + + Args: + zone_id: Identifier. + + operation_id: UUID. + + managed: List of managed label names. Omitting this property or passing an empty array + will result in all managed labels being removed from the operation + + user: List of user label names. Omitting this property or passing an empty array will + result in all user labels being removed from the operation + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + body=maybe_transform( + { + "managed": managed, + "user": user, + }, + label_update_params.LabelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LabelUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[LabelUpdateResponse], ResultWrapper[LabelUpdateResponse]), + ) + + def delete( + self, + operation_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LabelDeleteResponse: + """ + Remove label(s) on an operation in endpoint management + + Args: + zone_id: Identifier. + + operation_id: UUID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LabelDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[LabelDeleteResponse], ResultWrapper[LabelDeleteResponse]), + ) + + def bulk_create( + self, + *, + zone_id: str, + selector: label_bulk_create_params.Selector, + managed: label_bulk_create_params.Managed | Omit = omit, + user: label_bulk_create_params.User | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[LabelBulkCreateResponse]: + """ + Bulk attach label(s) on operation(s) in endpoint management + + Args: + zone_id: Identifier. + + selector: Operation IDs selector + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/operations/labels", + page=SyncSinglePage[LabelBulkCreateResponse], + body=maybe_transform( + { + "selector": selector, + "managed": managed, + "user": user, + }, + label_bulk_create_params.LabelBulkCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=LabelBulkCreateResponse, + method="post", + ) + + def bulk_delete( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[LabelBulkDeleteResponse]: + """ + Bulk remove label(s) on operation(s) in endpoint management + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/operations/labels", + page=SyncSinglePage[LabelBulkDeleteResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=LabelBulkDeleteResponse, + method="delete", + ) + + def bulk_update( + self, + *, + zone_id: str, + managed: label_bulk_update_params.Managed, + selector: label_bulk_update_params.Selector, + user: label_bulk_update_params.User, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[LabelBulkUpdateResponse]: + """ + Bulk replace label(s) on operation(s) in endpoint management + + Args: + zone_id: Identifier. + + managed: Managed labels to replace for all affected operations + + selector: Operation IDs selector + + user: User labels to replace for all affected operations + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/operations/labels", + page=SyncSinglePage[LabelBulkUpdateResponse], + body=maybe_transform( + { + "managed": managed, + "selector": selector, + "user": user, + }, + label_bulk_update_params.LabelBulkUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=LabelBulkUpdateResponse, + method="put", + ) + + +class AsyncLabelsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncLabelsResourceWithRawResponse: + """ + 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 AsyncLabelsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLabelsResourceWithStreamingResponse: + """ + 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 AsyncLabelsResourceWithStreamingResponse(self) + + async def create( + self, + operation_id: str, + *, + zone_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LabelCreateResponse: + """ + Attach label(s) on an operation in endpoint management + + Args: + zone_id: Identifier. + + operation_id: UUID. + + managed: List of managed label names. + + user: List of user label names. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + body=await async_maybe_transform( + { + "managed": managed, + "user": user, + }, + label_create_params.LabelCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LabelCreateResponse]._unwrapper, + ), + cast_to=cast(Type[LabelCreateResponse], ResultWrapper[LabelCreateResponse]), + ) + + async def update( + self, + operation_id: str, + *, + zone_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LabelUpdateResponse: + """ + Replace label(s) on an operation in endpoint management + + Args: + zone_id: Identifier. + + operation_id: UUID. + + managed: List of managed label names. Omitting this property or passing an empty array + will result in all managed labels being removed from the operation + + user: List of user label names. Omitting this property or passing an empty array will + result in all user labels being removed from the operation + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + body=await async_maybe_transform( + { + "managed": managed, + "user": user, + }, + label_update_params.LabelUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LabelUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[LabelUpdateResponse], ResultWrapper[LabelUpdateResponse]), + ) + + async def delete( + self, + operation_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LabelDeleteResponse: + """ + Remove label(s) on an operation in endpoint management + + Args: + zone_id: Identifier. + + operation_id: UUID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + 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", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LabelDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[LabelDeleteResponse], ResultWrapper[LabelDeleteResponse]), + ) + + def bulk_create( + self, + *, + zone_id: str, + selector: label_bulk_create_params.Selector, + managed: label_bulk_create_params.Managed | Omit = omit, + user: label_bulk_create_params.User | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[LabelBulkCreateResponse, AsyncSinglePage[LabelBulkCreateResponse]]: + """ + Bulk attach label(s) on operation(s) in endpoint management + + Args: + zone_id: Identifier. + + selector: Operation IDs selector + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/operations/labels", + page=AsyncSinglePage[LabelBulkCreateResponse], + body=maybe_transform( + { + "selector": selector, + "managed": managed, + "user": user, + }, + label_bulk_create_params.LabelBulkCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=LabelBulkCreateResponse, + method="post", + ) + + def bulk_delete( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[LabelBulkDeleteResponse, AsyncSinglePage[LabelBulkDeleteResponse]]: + """ + Bulk remove label(s) on operation(s) in endpoint management + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/operations/labels", + page=AsyncSinglePage[LabelBulkDeleteResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=LabelBulkDeleteResponse, + method="delete", + ) + + def bulk_update( + self, + *, + zone_id: str, + managed: label_bulk_update_params.Managed, + selector: label_bulk_update_params.Selector, + user: label_bulk_update_params.User, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this 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[LabelBulkUpdateResponse, AsyncSinglePage[LabelBulkUpdateResponse]]: + """ + Bulk replace label(s) on operation(s) in endpoint management + + Args: + zone_id: Identifier. + + managed: Managed labels to replace for all affected operations + + selector: Operation IDs selector + + user: User labels to replace for all affected operations + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/operations/labels", + page=AsyncSinglePage[LabelBulkUpdateResponse], + body=maybe_transform( + { + "managed": managed, + "selector": selector, + "user": user, + }, + label_bulk_update_params.LabelBulkUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=LabelBulkUpdateResponse, + method="put", + ) + + +class LabelsResourceWithRawResponse: + def __init__(self, labels: LabelsResource) -> None: + self._labels = labels + + self.create = to_raw_response_wrapper( + labels.create, + ) + self.update = to_raw_response_wrapper( + labels.update, + ) + self.delete = to_raw_response_wrapper( + labels.delete, + ) + self.bulk_create = to_raw_response_wrapper( + labels.bulk_create, + ) + self.bulk_delete = to_raw_response_wrapper( + labels.bulk_delete, + ) + self.bulk_update = to_raw_response_wrapper( + labels.bulk_update, + ) + + +class AsyncLabelsResourceWithRawResponse: + def __init__(self, labels: AsyncLabelsResource) -> None: + self._labels = labels + + self.create = async_to_raw_response_wrapper( + labels.create, + ) + self.update = async_to_raw_response_wrapper( + labels.update, + ) + self.delete = async_to_raw_response_wrapper( + labels.delete, + ) + self.bulk_create = async_to_raw_response_wrapper( + labels.bulk_create, + ) + self.bulk_delete = async_to_raw_response_wrapper( + labels.bulk_delete, + ) + self.bulk_update = async_to_raw_response_wrapper( + labels.bulk_update, + ) + + +class LabelsResourceWithStreamingResponse: + def __init__(self, labels: LabelsResource) -> None: + self._labels = labels + + self.create = to_streamed_response_wrapper( + labels.create, + ) + self.update = to_streamed_response_wrapper( + labels.update, + ) + self.delete = to_streamed_response_wrapper( + labels.delete, + ) + self.bulk_create = to_streamed_response_wrapper( + labels.bulk_create, + ) + self.bulk_delete = to_streamed_response_wrapper( + labels.bulk_delete, + ) + self.bulk_update = to_streamed_response_wrapper( + labels.bulk_update, + ) + + +class AsyncLabelsResourceWithStreamingResponse: + def __init__(self, labels: AsyncLabelsResource) -> None: + self._labels = labels + + self.create = async_to_streamed_response_wrapper( + labels.create, + ) + self.update = async_to_streamed_response_wrapper( + labels.update, + ) + self.delete = async_to_streamed_response_wrapper( + labels.delete, + ) + self.bulk_create = async_to_streamed_response_wrapper( + labels.bulk_create, + ) + self.bulk_delete = async_to_streamed_response_wrapper( + labels.bulk_delete, + ) + self.bulk_update = async_to_streamed_response_wrapper( + labels.bulk_update, + ) diff --git a/src/cloudflare/resources/api_gateway/operations/operations.py b/src/cloudflare/resources/api_gateway/operations/operations.py index 1a6038c3688..31189308551 100644 --- a/src/cloudflare/resources/api_gateway/operations/operations.py +++ b/src/cloudflare/resources/api_gateway/operations/operations.py @@ -7,6 +7,14 @@ import httpx +from .labels import ( + LabelsResource, + AsyncLabelsResource, + LabelsResourceWithRawResponse, + AsyncLabelsResourceWithRawResponse, + LabelsResourceWithStreamingResponse, + AsyncLabelsResourceWithStreamingResponse, +) 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 @@ -45,6 +53,10 @@ class OperationsResource(SyncAPIResource): + @cached_property + def labels(self) -> LabelsResource: + return LabelsResource(self._client) + @cached_property def schema_validation(self) -> SchemaValidationResource: return SchemaValidationResource(self._client) @@ -152,7 +164,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[OperationListResponse]: """ - Retrieve information about all operations on a zone + Lists all API operations tracked by API Shield for a zone with pagination. + Returns operation details including method, path, and feature configurations. Args: zone_id: Identifier. @@ -223,8 +236,10 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationDeleteResponse: - """ - Delete an operation + """Removes a single API operation from API Shield endpoint management. + + The + operation will no longer be tracked or protected by API Shield rules. Args: zone_id: Identifier. @@ -307,7 +322,8 @@ def bulk_delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationBulkDeleteResponse: """ - Delete multiple operations + Bulk removes multiple API operations from API Shield endpoint management in a + single request. Efficient for cleaning up unused endpoints. Args: zone_id: Identifier. @@ -344,7 +360,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationGetResponse: """ - Retrieve information about an operation + Gets detailed information about a specific API operation in API Shield, + including its schema validation settings and traffic statistics. Args: zone_id: Identifier. @@ -382,6 +399,10 @@ def get( class AsyncOperationsResource(AsyncAPIResource): + @cached_property + def labels(self) -> AsyncLabelsResource: + return AsyncLabelsResource(self._client) + @cached_property def schema_validation(self) -> AsyncSchemaValidationResource: return AsyncSchemaValidationResource(self._client) @@ -489,7 +510,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[OperationListResponse, AsyncV4PagePaginationArray[OperationListResponse]]: """ - Retrieve information about all operations on a zone + Lists all API operations tracked by API Shield for a zone with pagination. + Returns operation details including method, path, and feature configurations. Args: zone_id: Identifier. @@ -560,8 +582,10 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationDeleteResponse: - """ - Delete an operation + """Removes a single API operation from API Shield endpoint management. + + The + operation will no longer be tracked or protected by API Shield rules. Args: zone_id: Identifier. @@ -644,7 +668,8 @@ async def bulk_delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationBulkDeleteResponse: """ - Delete multiple operations + Bulk removes multiple API operations from API Shield endpoint management in a + single request. Efficient for cleaning up unused endpoints. Args: zone_id: Identifier. @@ -681,7 +706,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationGetResponse: """ - Retrieve information about an operation + Gets detailed information about a specific API operation in API Shield, + including its schema validation settings and traffic statistics. Args: zone_id: Identifier. @@ -741,6 +767,10 @@ def __init__(self, operations: OperationsResource) -> None: operations.get, ) + @cached_property + def labels(self) -> LabelsResourceWithRawResponse: + return LabelsResourceWithRawResponse(self._operations.labels) + @cached_property def schema_validation(self) -> SchemaValidationResourceWithRawResponse: return SchemaValidationResourceWithRawResponse(self._operations.schema_validation) @@ -769,6 +799,10 @@ def __init__(self, operations: AsyncOperationsResource) -> None: operations.get, ) + @cached_property + def labels(self) -> AsyncLabelsResourceWithRawResponse: + return AsyncLabelsResourceWithRawResponse(self._operations.labels) + @cached_property def schema_validation(self) -> AsyncSchemaValidationResourceWithRawResponse: return AsyncSchemaValidationResourceWithRawResponse(self._operations.schema_validation) @@ -797,6 +831,10 @@ def __init__(self, operations: OperationsResource) -> None: operations.get, ) + @cached_property + def labels(self) -> LabelsResourceWithStreamingResponse: + return LabelsResourceWithStreamingResponse(self._operations.labels) + @cached_property def schema_validation(self) -> SchemaValidationResourceWithStreamingResponse: return SchemaValidationResourceWithStreamingResponse(self._operations.schema_validation) @@ -825,6 +863,10 @@ def __init__(self, operations: AsyncOperationsResource) -> None: operations.get, ) + @cached_property + def labels(self) -> AsyncLabelsResourceWithStreamingResponse: + return AsyncLabelsResourceWithStreamingResponse(self._operations.labels) + @cached_property def schema_validation(self) -> AsyncSchemaValidationResourceWithStreamingResponse: return AsyncSchemaValidationResourceWithStreamingResponse(self._operations.schema_validation) diff --git a/src/cloudflare/resources/api_gateway/user_schemas/hosts.py b/src/cloudflare/resources/api_gateway/user_schemas/hosts.py index 01861b64473..d193678ec7d 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/hosts.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/hosts.py @@ -60,8 +60,10 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[HostListResponse]: - """ - Retrieve schema hosts in a zone + """Lists all unique hosts found in uploaded OpenAPI schemas for the zone. + + Useful + for understanding which domains have schema coverage. Args: zone_id: Identifier. @@ -136,8 +138,10 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[HostListResponse, AsyncV4PagePaginationArray[HostListResponse]]: - """ - Retrieve schema hosts in a zone + """Lists all unique hosts found in uploaded OpenAPI schemas for the zone. + + Useful + for understanding which domains have schema coverage. Args: zone_id: Identifier. 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 e7d9626a705..346db5396d5 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py @@ -166,7 +166,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[OldPublicSchema]: """ - Retrieve information about all schemas on a zone + Lists all OpenAPI schemas uploaded to API Shield for the zone, including their + validation status and associated operations. Args: zone_id: Identifier. @@ -225,8 +226,10 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> UserSchemaDeleteResponse: - """ - Delete a schema + """Permanently removes an uploaded OpenAPI schema from API Shield schema + validation. + + Operations using this schema will lose their validation rules. Args: zone_id: Identifier. @@ -267,8 +270,10 @@ def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OldPublicSchema: - """ - Enable validation for a schema + """Activates schema validation for an uploaded OpenAPI schema. + + Requests to matching + endpoints will be validated against the schema definitions. Args: zone_id: Identifier. @@ -319,7 +324,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OldPublicSchema: """ - Retrieve information about a specific schema on a zone + Gets detailed information about a specific uploaded OpenAPI schema, including + its contents and validation configuration. Args: zone_id: Identifier. @@ -468,7 +474,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[OldPublicSchema, AsyncV4PagePaginationArray[OldPublicSchema]]: """ - Retrieve information about all schemas on a zone + Lists all OpenAPI schemas uploaded to API Shield for the zone, including their + validation status and associated operations. Args: zone_id: Identifier. @@ -527,8 +534,10 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> UserSchemaDeleteResponse: - """ - Delete a schema + """Permanently removes an uploaded OpenAPI schema from API Shield schema + validation. + + Operations using this schema will lose their validation rules. Args: zone_id: Identifier. @@ -569,8 +578,10 @@ async def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OldPublicSchema: - """ - Enable validation for a schema + """Activates schema validation for an uploaded OpenAPI schema. + + Requests to matching + endpoints will be validated against the schema definitions. Args: zone_id: Identifier. @@ -621,7 +632,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OldPublicSchema: """ - Retrieve information about a specific schema on a zone + Gets detailed information about a specific uploaded OpenAPI schema, including + its contents and validation configuration. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/billing/__init__.py b/src/cloudflare/resources/billing/__init__.py index c16ec03c4dc..a0005fa8305 100644 --- a/src/cloudflare/resources/billing/__init__.py +++ b/src/cloudflare/resources/billing/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .usage import ( + UsageResource, + AsyncUsageResource, + UsageResourceWithRawResponse, + AsyncUsageResourceWithRawResponse, + UsageResourceWithStreamingResponse, + AsyncUsageResourceWithStreamingResponse, +) from .billing import ( BillingResource, AsyncBillingResource, @@ -24,6 +32,12 @@ "AsyncProfilesResourceWithRawResponse", "ProfilesResourceWithStreamingResponse", "AsyncProfilesResourceWithStreamingResponse", + "UsageResource", + "AsyncUsageResource", + "UsageResourceWithRawResponse", + "AsyncUsageResourceWithRawResponse", + "UsageResourceWithStreamingResponse", + "AsyncUsageResourceWithStreamingResponse", "BillingResource", "AsyncBillingResource", "BillingResourceWithRawResponse", diff --git a/src/cloudflare/resources/billing/billing.py b/src/cloudflare/resources/billing/billing.py index d57c019144e..5d7a8e1d11a 100644 --- a/src/cloudflare/resources/billing/billing.py +++ b/src/cloudflare/resources/billing/billing.py @@ -2,6 +2,14 @@ from __future__ import annotations +from .usage import ( + UsageResource, + AsyncUsageResource, + UsageResourceWithRawResponse, + AsyncUsageResourceWithRawResponse, + UsageResourceWithStreamingResponse, + AsyncUsageResourceWithStreamingResponse, +) from .profiles import ( ProfilesResource, AsyncProfilesResource, @@ -21,6 +29,10 @@ class BillingResource(SyncAPIResource): def profiles(self) -> ProfilesResource: return ProfilesResource(self._client) + @cached_property + def usage(self) -> UsageResource: + return UsageResource(self._client) + @cached_property def with_raw_response(self) -> BillingResourceWithRawResponse: """ @@ -46,6 +58,10 @@ class AsyncBillingResource(AsyncAPIResource): def profiles(self) -> AsyncProfilesResource: return AsyncProfilesResource(self._client) + @cached_property + def usage(self) -> AsyncUsageResource: + return AsyncUsageResource(self._client) + @cached_property def with_raw_response(self) -> AsyncBillingResourceWithRawResponse: """ @@ -74,6 +90,10 @@ def __init__(self, billing: BillingResource) -> None: def profiles(self) -> ProfilesResourceWithRawResponse: return ProfilesResourceWithRawResponse(self._billing.profiles) + @cached_property + def usage(self) -> UsageResourceWithRawResponse: + return UsageResourceWithRawResponse(self._billing.usage) + class AsyncBillingResourceWithRawResponse: def __init__(self, billing: AsyncBillingResource) -> None: @@ -83,6 +103,10 @@ def __init__(self, billing: AsyncBillingResource) -> None: def profiles(self) -> AsyncProfilesResourceWithRawResponse: return AsyncProfilesResourceWithRawResponse(self._billing.profiles) + @cached_property + def usage(self) -> AsyncUsageResourceWithRawResponse: + return AsyncUsageResourceWithRawResponse(self._billing.usage) + class BillingResourceWithStreamingResponse: def __init__(self, billing: BillingResource) -> None: @@ -92,6 +116,10 @@ def __init__(self, billing: BillingResource) -> None: def profiles(self) -> ProfilesResourceWithStreamingResponse: return ProfilesResourceWithStreamingResponse(self._billing.profiles) + @cached_property + def usage(self) -> UsageResourceWithStreamingResponse: + return UsageResourceWithStreamingResponse(self._billing.usage) + class AsyncBillingResourceWithStreamingResponse: def __init__(self, billing: AsyncBillingResource) -> None: @@ -100,3 +128,7 @@ def __init__(self, billing: AsyncBillingResource) -> None: @cached_property def profiles(self) -> AsyncProfilesResourceWithStreamingResponse: return AsyncProfilesResourceWithStreamingResponse(self._billing.profiles) + + @cached_property + def usage(self) -> AsyncUsageResourceWithStreamingResponse: + return AsyncUsageResourceWithStreamingResponse(self._billing.usage) diff --git a/src/cloudflare/resources/billing/usage.py b/src/cloudflare/resources/billing/usage.py new file mode 100644 index 00000000000..d9841c26684 --- /dev/null +++ b/src/cloudflare/resources/billing/usage.py @@ -0,0 +1,213 @@ +# 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 + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.billing import usage_paygo_params +from ...types.billing.usage_paygo_response import UsagePaygoResponse + +__all__ = ["UsageResource", "AsyncUsageResource"] + + +class UsageResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> UsageResourceWithRawResponse: + """ + 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 UsageResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> UsageResourceWithStreamingResponse: + """ + 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 UsageResourceWithStreamingResponse(self) + + def paygo( + self, + *, + account_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UsagePaygoResponse: + """Returns billable usage data for PayGo (self-serve) accounts. + + When no query + parameters are provided, returns usage for the current billing period. This + endpoint is currently in beta and access is restricted to select accounts. + + Args: + account_id: Represents a Cloudflare resource identifier tag. + + from_: Defines the start date for the usage query (e.g., 2025-02-01). + + to: Defines the end date for the usage query (e.g., 2025-03-01). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/billing/usage/paygo", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "from_": from_, + "to": to, + }, + usage_paygo_params.UsagePaygoParams, + ), + post_parser=ResultWrapper[UsagePaygoResponse]._unwrapper, + ), + cast_to=cast(Type[UsagePaygoResponse], ResultWrapper[UsagePaygoResponse]), + ) + + +class AsyncUsageResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncUsageResourceWithRawResponse: + """ + 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 AsyncUsageResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncUsageResourceWithStreamingResponse: + """ + 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 AsyncUsageResourceWithStreamingResponse(self) + + async def paygo( + self, + *, + account_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UsagePaygoResponse: + """Returns billable usage data for PayGo (self-serve) accounts. + + When no query + parameters are provided, returns usage for the current billing period. This + endpoint is currently in beta and access is restricted to select accounts. + + Args: + account_id: Represents a Cloudflare resource identifier tag. + + from_: Defines the start date for the usage query (e.g., 2025-02-01). + + to: Defines the end date for the usage query (e.g., 2025-03-01). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/billing/usage/paygo", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "from_": from_, + "to": to, + }, + usage_paygo_params.UsagePaygoParams, + ), + post_parser=ResultWrapper[UsagePaygoResponse]._unwrapper, + ), + cast_to=cast(Type[UsagePaygoResponse], ResultWrapper[UsagePaygoResponse]), + ) + + +class UsageResourceWithRawResponse: + def __init__(self, usage: UsageResource) -> None: + self._usage = usage + + self.paygo = to_raw_response_wrapper( + usage.paygo, + ) + + +class AsyncUsageResourceWithRawResponse: + def __init__(self, usage: AsyncUsageResource) -> None: + self._usage = usage + + self.paygo = async_to_raw_response_wrapper( + usage.paygo, + ) + + +class UsageResourceWithStreamingResponse: + def __init__(self, usage: UsageResource) -> None: + self._usage = usage + + self.paygo = to_streamed_response_wrapper( + usage.paygo, + ) + + +class AsyncUsageResourceWithStreamingResponse: + def __init__(self, usage: AsyncUsageResource) -> None: + self._usage = usage + + self.paygo = async_to_streamed_response_wrapper( + usage.paygo, + ) diff --git a/src/cloudflare/resources/brand_protection/__init__.py b/src/cloudflare/resources/brand_protection/__init__.py index 1660f110c9b..a27726071c4 100644 --- a/src/cloudflare/resources/brand_protection/__init__.py +++ b/src/cloudflare/resources/brand_protection/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .v2 import ( + V2Resource, + AsyncV2Resource, + V2ResourceWithRawResponse, + AsyncV2ResourceWithRawResponse, + V2ResourceWithStreamingResponse, + AsyncV2ResourceWithStreamingResponse, +) from .logos import ( LogosResource, AsyncLogosResource, @@ -66,6 +74,12 @@ "AsyncLogoMatchesResourceWithRawResponse", "LogoMatchesResourceWithStreamingResponse", "AsyncLogoMatchesResourceWithStreamingResponse", + "V2Resource", + "AsyncV2Resource", + "V2ResourceWithRawResponse", + "AsyncV2ResourceWithRawResponse", + "V2ResourceWithStreamingResponse", + "AsyncV2ResourceWithStreamingResponse", "BrandProtectionResource", "AsyncBrandProtectionResource", "BrandProtectionResourceWithRawResponse", diff --git a/src/cloudflare/resources/brand_protection/brand_protection.py b/src/cloudflare/resources/brand_protection/brand_protection.py index efe44ec7d57..c28e5602df7 100644 --- a/src/cloudflare/resources/brand_protection/brand_protection.py +++ b/src/cloudflare/resources/brand_protection/brand_protection.py @@ -12,6 +12,14 @@ LogosResourceWithStreamingResponse, AsyncLogosResourceWithStreamingResponse, ) +from .v2.v2 import ( + V2Resource, + AsyncV2Resource, + V2ResourceWithRawResponse, + AsyncV2ResourceWithRawResponse, + V2ResourceWithStreamingResponse, + AsyncV2ResourceWithStreamingResponse, +) from .matches import ( MatchesResource, AsyncMatchesResource, @@ -70,6 +78,10 @@ def logos(self) -> LogosResource: def logo_matches(self) -> LogoMatchesResource: return LogoMatchesResource(self._client) + @cached_property + def v2(self) -> V2Resource: + return V2Resource(self._client) + @cached_property def with_raw_response(self) -> BrandProtectionResourceWithRawResponse: """ @@ -174,6 +186,10 @@ def logos(self) -> AsyncLogosResource: def logo_matches(self) -> AsyncLogoMatchesResource: return AsyncLogoMatchesResource(self._client) + @cached_property + def v2(self) -> AsyncV2Resource: + return AsyncV2Resource(self._client) + @cached_property def with_raw_response(self) -> AsyncBrandProtectionResourceWithRawResponse: """ @@ -288,6 +304,10 @@ def logos(self) -> LogosResourceWithRawResponse: def logo_matches(self) -> LogoMatchesResourceWithRawResponse: return LogoMatchesResourceWithRawResponse(self._brand_protection.logo_matches) + @cached_property + def v2(self) -> V2ResourceWithRawResponse: + return V2ResourceWithRawResponse(self._brand_protection.v2) + class AsyncBrandProtectionResourceWithRawResponse: def __init__(self, brand_protection: AsyncBrandProtectionResource) -> None: @@ -316,6 +336,10 @@ def logos(self) -> AsyncLogosResourceWithRawResponse: def logo_matches(self) -> AsyncLogoMatchesResourceWithRawResponse: return AsyncLogoMatchesResourceWithRawResponse(self._brand_protection.logo_matches) + @cached_property + def v2(self) -> AsyncV2ResourceWithRawResponse: + return AsyncV2ResourceWithRawResponse(self._brand_protection.v2) + class BrandProtectionResourceWithStreamingResponse: def __init__(self, brand_protection: BrandProtectionResource) -> None: @@ -344,6 +368,10 @@ def logos(self) -> LogosResourceWithStreamingResponse: def logo_matches(self) -> LogoMatchesResourceWithStreamingResponse: return LogoMatchesResourceWithStreamingResponse(self._brand_protection.logo_matches) + @cached_property + def v2(self) -> V2ResourceWithStreamingResponse: + return V2ResourceWithStreamingResponse(self._brand_protection.v2) + class AsyncBrandProtectionResourceWithStreamingResponse: def __init__(self, brand_protection: AsyncBrandProtectionResource) -> None: @@ -371,3 +399,7 @@ def logos(self) -> AsyncLogosResourceWithStreamingResponse: @cached_property def logo_matches(self) -> AsyncLogoMatchesResourceWithStreamingResponse: return AsyncLogoMatchesResourceWithStreamingResponse(self._brand_protection.logo_matches) + + @cached_property + def v2(self) -> AsyncV2ResourceWithStreamingResponse: + return AsyncV2ResourceWithStreamingResponse(self._brand_protection.v2) diff --git a/src/cloudflare/resources/brand_protection/v2/__init__.py b/src/cloudflare/resources/brand_protection/v2/__init__.py new file mode 100644 index 00000000000..30145cd1f36 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/v2/__init__.py @@ -0,0 +1,75 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .v2 import ( + V2Resource, + AsyncV2Resource, + V2ResourceWithRawResponse, + AsyncV2ResourceWithRawResponse, + V2ResourceWithStreamingResponse, + AsyncV2ResourceWithStreamingResponse, +) +from .logos import ( + LogosResource, + AsyncLogosResource, + LogosResourceWithRawResponse, + AsyncLogosResourceWithRawResponse, + LogosResourceWithStreamingResponse, + AsyncLogosResourceWithStreamingResponse, +) +from .matches import ( + MatchesResource, + AsyncMatchesResource, + MatchesResourceWithRawResponse, + AsyncMatchesResourceWithRawResponse, + MatchesResourceWithStreamingResponse, + AsyncMatchesResourceWithStreamingResponse, +) +from .queries import ( + QueriesResource, + AsyncQueriesResource, + QueriesResourceWithRawResponse, + AsyncQueriesResourceWithRawResponse, + QueriesResourceWithStreamingResponse, + AsyncQueriesResourceWithStreamingResponse, +) +from .logo_matches import ( + LogoMatchesResource, + AsyncLogoMatchesResource, + LogoMatchesResourceWithRawResponse, + AsyncLogoMatchesResourceWithRawResponse, + LogoMatchesResourceWithStreamingResponse, + AsyncLogoMatchesResourceWithStreamingResponse, +) + +__all__ = [ + "QueriesResource", + "AsyncQueriesResource", + "QueriesResourceWithRawResponse", + "AsyncQueriesResourceWithRawResponse", + "QueriesResourceWithStreamingResponse", + "AsyncQueriesResourceWithStreamingResponse", + "MatchesResource", + "AsyncMatchesResource", + "MatchesResourceWithRawResponse", + "AsyncMatchesResourceWithRawResponse", + "MatchesResourceWithStreamingResponse", + "AsyncMatchesResourceWithStreamingResponse", + "LogosResource", + "AsyncLogosResource", + "LogosResourceWithRawResponse", + "AsyncLogosResourceWithRawResponse", + "LogosResourceWithStreamingResponse", + "AsyncLogosResourceWithStreamingResponse", + "LogoMatchesResource", + "AsyncLogoMatchesResource", + "LogoMatchesResourceWithRawResponse", + "AsyncLogoMatchesResourceWithRawResponse", + "LogoMatchesResourceWithStreamingResponse", + "AsyncLogoMatchesResourceWithStreamingResponse", + "V2Resource", + "AsyncV2Resource", + "V2ResourceWithRawResponse", + "AsyncV2ResourceWithRawResponse", + "V2ResourceWithStreamingResponse", + "AsyncV2ResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/brand_protection/v2/logo_matches.py b/src/cloudflare/resources/brand_protection/v2/logo_matches.py new file mode 100644 index 00000000000..719aa327eff --- /dev/null +++ b/src/cloudflare/resources/brand_protection/v2/logo_matches.py @@ -0,0 +1,215 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.brand_protection.v2 import logo_match_get_params +from ....types.brand_protection.v2.logo_match_get_response import LogoMatchGetResponse + +__all__ = ["LogoMatchesResource", "AsyncLogoMatchesResource"] + + +class LogoMatchesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> LogoMatchesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return LogoMatchesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LogoMatchesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return LogoMatchesResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str, + query_id: str, + download: str | Omit = omit, + limit: str | Omit = omit, + offset: str | Omit = omit, + order: Literal["asc", "desc"] | Omit = omit, + order_by: Literal["matchedAt", "domain", "similarityScore"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoMatchGetResponse: + """ + Get paginated list of logo matches for a specific brand protection logo query + + Args: + order: Sort order. Options: 'asc' (ascending) or 'desc' (descending) + + order_by: Column to sort by. Options: 'matchedAt', 'domain', or 'similarityScore' + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/matches", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "query_id": query_id, + "download": download, + "limit": limit, + "offset": offset, + "order": order, + "order_by": order_by, + }, + logo_match_get_params.LogoMatchGetParams, + ), + ), + cast_to=LogoMatchGetResponse, + ) + + +class AsyncLogoMatchesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncLogoMatchesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncLogoMatchesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLogoMatchesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncLogoMatchesResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str, + query_id: str, + download: str | Omit = omit, + limit: str | Omit = omit, + offset: str | Omit = omit, + order: Literal["asc", "desc"] | Omit = omit, + order_by: Literal["matchedAt", "domain", "similarityScore"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoMatchGetResponse: + """ + Get paginated list of logo matches for a specific brand protection logo query + + Args: + order: Sort order. Options: 'asc' (ascending) or 'desc' (descending) + + order_by: Column to sort by. Options: 'matchedAt', 'domain', or 'similarityScore' + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/matches", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "query_id": query_id, + "download": download, + "limit": limit, + "offset": offset, + "order": order, + "order_by": order_by, + }, + logo_match_get_params.LogoMatchGetParams, + ), + ), + cast_to=LogoMatchGetResponse, + ) + + +class LogoMatchesResourceWithRawResponse: + def __init__(self, logo_matches: LogoMatchesResource) -> None: + self._logo_matches = logo_matches + + self.get = to_raw_response_wrapper( + logo_matches.get, + ) + + +class AsyncLogoMatchesResourceWithRawResponse: + def __init__(self, logo_matches: AsyncLogoMatchesResource) -> None: + self._logo_matches = logo_matches + + self.get = async_to_raw_response_wrapper( + logo_matches.get, + ) + + +class LogoMatchesResourceWithStreamingResponse: + def __init__(self, logo_matches: LogoMatchesResource) -> None: + self._logo_matches = logo_matches + + self.get = to_streamed_response_wrapper( + logo_matches.get, + ) + + +class AsyncLogoMatchesResourceWithStreamingResponse: + def __init__(self, logo_matches: AsyncLogoMatchesResource) -> None: + self._logo_matches = logo_matches + + self.get = async_to_streamed_response_wrapper( + logo_matches.get, + ) diff --git a/src/cloudflare/resources/brand_protection/v2/logos.py b/src/cloudflare/resources/brand_protection/v2/logos.py new file mode 100644 index 00000000000..5787bf1bed6 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/v2/logos.py @@ -0,0 +1,417 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.brand_protection.v2 import logo_get_params, logo_create_params +from ....types.brand_protection.v2.logo_get_response import LogoGetResponse +from ....types.brand_protection.v2.logo_create_response import LogoCreateResponse +from ....types.brand_protection.v2.logo_delete_response import LogoDeleteResponse + +__all__ = ["LogosResource", "AsyncLogosResource"] + + +class LogosResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> LogosResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return LogosResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LogosResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return LogosResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + image_data: str, + similarity_threshold: float, + tag: str, + search_lookback: 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, + ) -> LogoCreateResponse: + """ + Create a new saved brand protection logo query for visual similarity matching + + Args: + image_data: Base64 encoded image data. Can include data URI prefix (e.g., + 'data:image/png;base64,...') or just the base64 string. + + similarity_threshold: Minimum similarity score (0-1) required for visual matches + + tag: Unique identifier for the logo query + + search_lookback: If true, search historic scanned images for matches above the similarity + threshold + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries", + body=maybe_transform( + { + "image_data": image_data, + "similarity_threshold": similarity_threshold, + "tag": tag, + "search_lookback": search_lookback, + }, + logo_create_params.LogoCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=LogoCreateResponse, + ) + + def delete( + self, + query_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoDeleteResponse: + """Delete a saved brand protection logo query. + + Returns 404 if the query ID doesn't + exist. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not 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}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=LogoDeleteResponse, + ) + + def get( + self, + *, + account_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoGetResponse: + """Get all saved brand protection logo queries for an account. + + Optionally specify + id to get a single query. Set download=true to include base64-encoded image + data. + + Args: + id: Optional query ID to retrieve a specific logo query + + download: If true, include base64-encoded image data 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 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", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "download": download, + }, + logo_get_params.LogoGetParams, + ), + ), + cast_to=LogoGetResponse, + ) + + +class AsyncLogosResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncLogosResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncLogosResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLogosResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncLogosResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + image_data: str, + similarity_threshold: float, + tag: str, + search_lookback: 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, + ) -> LogoCreateResponse: + """ + Create a new saved brand protection logo query for visual similarity matching + + Args: + image_data: Base64 encoded image data. Can include data URI prefix (e.g., + 'data:image/png;base64,...') or just the base64 string. + + similarity_threshold: Minimum similarity score (0-1) required for visual matches + + tag: Unique identifier for the logo query + + search_lookback: If true, search historic scanned images for matches above the similarity + threshold + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries", + body=await async_maybe_transform( + { + "image_data": image_data, + "similarity_threshold": similarity_threshold, + "tag": tag, + "search_lookback": search_lookback, + }, + logo_create_params.LogoCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=LogoCreateResponse, + ) + + async def delete( + self, + query_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoDeleteResponse: + """Delete a saved brand protection logo query. + + Returns 404 if the query ID doesn't + exist. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not 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}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=LogoDeleteResponse, + ) + + async def get( + self, + *, + account_id: str, + 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. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoGetResponse: + """Get all saved brand protection logo queries for an account. + + Optionally specify + id to get a single query. Set download=true to include base64-encoded image + data. + + Args: + id: Optional query ID to retrieve a specific logo query + + download: If true, include base64-encoded image data 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 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", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "id": id, + "download": download, + }, + logo_get_params.LogoGetParams, + ), + ), + cast_to=LogoGetResponse, + ) + + +class LogosResourceWithRawResponse: + def __init__(self, logos: LogosResource) -> None: + self._logos = logos + + self.create = to_raw_response_wrapper( + logos.create, + ) + self.delete = to_raw_response_wrapper( + logos.delete, + ) + self.get = to_raw_response_wrapper( + logos.get, + ) + + +class AsyncLogosResourceWithRawResponse: + def __init__(self, logos: AsyncLogosResource) -> None: + self._logos = logos + + self.create = async_to_raw_response_wrapper( + logos.create, + ) + self.delete = async_to_raw_response_wrapper( + logos.delete, + ) + self.get = async_to_raw_response_wrapper( + logos.get, + ) + + +class LogosResourceWithStreamingResponse: + def __init__(self, logos: LogosResource) -> None: + self._logos = logos + + self.create = to_streamed_response_wrapper( + logos.create, + ) + self.delete = to_streamed_response_wrapper( + logos.delete, + ) + self.get = to_streamed_response_wrapper( + logos.get, + ) + + +class AsyncLogosResourceWithStreamingResponse: + def __init__(self, logos: AsyncLogosResource) -> None: + self._logos = logos + + self.create = async_to_streamed_response_wrapper( + logos.create, + ) + self.delete = async_to_streamed_response_wrapper( + logos.delete, + ) + self.get = async_to_streamed_response_wrapper( + logos.get, + ) diff --git a/src/cloudflare/resources/brand_protection/v2/matches.py b/src/cloudflare/resources/brand_protection/v2/matches.py new file mode 100644 index 00000000000..83ba27d7309 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/v2/matches.py @@ -0,0 +1,219 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.brand_protection.v2 import match_get_params +from ....types.brand_protection.v2.match_get_response import MatchGetResponse + +__all__ = ["MatchesResource", "AsyncMatchesResource"] + + +class MatchesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> MatchesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return MatchesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MatchesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return MatchesResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str, + query_id: str, + include_dismissed: str | Omit = omit, + include_domain_id: str | Omit = omit, + limit: str | Omit = omit, + offset: str | Omit = omit, + order: Literal["asc", "desc"] | Omit = omit, + order_by: Literal["domain", "first_seen"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MatchGetResponse: + """ + Get paginated list of domain matches for a specific brand protection query + + Args: + order: Sort order. Options: 'asc' (ascending) or 'desc' (descending) + + order_by: Column to sort by. Options: 'domain' or 'first_seen' + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/matches", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "query_id": query_id, + "include_dismissed": include_dismissed, + "include_domain_id": include_domain_id, + "limit": limit, + "offset": offset, + "order": order, + "order_by": order_by, + }, + match_get_params.MatchGetParams, + ), + ), + cast_to=MatchGetResponse, + ) + + +class AsyncMatchesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncMatchesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncMatchesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMatchesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncMatchesResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str, + query_id: str, + include_dismissed: str | Omit = omit, + include_domain_id: str | Omit = omit, + limit: str | Omit = omit, + offset: str | Omit = omit, + order: Literal["asc", "desc"] | Omit = omit, + order_by: Literal["domain", "first_seen"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MatchGetResponse: + """ + Get paginated list of domain matches for a specific brand protection query + + Args: + order: Sort order. Options: 'asc' (ascending) or 'desc' (descending) + + order_by: Column to sort by. Options: 'domain' or 'first_seen' + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/matches", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "query_id": query_id, + "include_dismissed": include_dismissed, + "include_domain_id": include_domain_id, + "limit": limit, + "offset": offset, + "order": order, + "order_by": order_by, + }, + match_get_params.MatchGetParams, + ), + ), + cast_to=MatchGetResponse, + ) + + +class MatchesResourceWithRawResponse: + def __init__(self, matches: MatchesResource) -> None: + self._matches = matches + + self.get = to_raw_response_wrapper( + matches.get, + ) + + +class AsyncMatchesResourceWithRawResponse: + def __init__(self, matches: AsyncMatchesResource) -> None: + self._matches = matches + + self.get = async_to_raw_response_wrapper( + matches.get, + ) + + +class MatchesResourceWithStreamingResponse: + def __init__(self, matches: MatchesResource) -> None: + self._matches = matches + + self.get = to_streamed_response_wrapper( + matches.get, + ) + + +class AsyncMatchesResourceWithStreamingResponse: + def __init__(self, matches: AsyncMatchesResource) -> None: + self._matches = matches + + self.get = async_to_streamed_response_wrapper( + matches.get, + ) diff --git a/src/cloudflare/resources/brand_protection/v2/queries.py b/src/cloudflare/resources/brand_protection/v2/queries.py new file mode 100644 index 00000000000..a632d5e3e35 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/v2/queries.py @@ -0,0 +1,175 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.brand_protection.v2 import query_get_params +from ....types.brand_protection.v2.query_get_response import QueryGetResponse + +__all__ = ["QueriesResource", "AsyncQueriesResource"] + + +class QueriesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> QueriesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return QueriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> QueriesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return QueriesResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str, + 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, + ) -> QueryGetResponse: + """ + Get all saved brand protection queries for an account + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/queries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"id": id}, query_get_params.QueryGetParams), + ), + cast_to=QueryGetResponse, + ) + + +class AsyncQueriesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncQueriesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncQueriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncQueriesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncQueriesResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str, + 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, + ) -> QueryGetResponse: + """ + Get all saved brand protection queries for an account + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/queries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"id": id}, query_get_params.QueryGetParams), + ), + cast_to=QueryGetResponse, + ) + + +class QueriesResourceWithRawResponse: + def __init__(self, queries: QueriesResource) -> None: + self._queries = queries + + self.get = to_raw_response_wrapper( + queries.get, + ) + + +class AsyncQueriesResourceWithRawResponse: + def __init__(self, queries: AsyncQueriesResource) -> None: + self._queries = queries + + self.get = async_to_raw_response_wrapper( + queries.get, + ) + + +class QueriesResourceWithStreamingResponse: + def __init__(self, queries: QueriesResource) -> None: + self._queries = queries + + self.get = to_streamed_response_wrapper( + queries.get, + ) + + +class AsyncQueriesResourceWithStreamingResponse: + def __init__(self, queries: AsyncQueriesResource) -> None: + self._queries = queries + + self.get = async_to_streamed_response_wrapper( + queries.get, + ) diff --git a/src/cloudflare/resources/brand_protection/v2/v2.py b/src/cloudflare/resources/brand_protection/v2/v2.py new file mode 100644 index 00000000000..0045a6cd48b --- /dev/null +++ b/src/cloudflare/resources/brand_protection/v2/v2.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .logos import ( + LogosResource, + AsyncLogosResource, + LogosResourceWithRawResponse, + AsyncLogosResourceWithRawResponse, + LogosResourceWithStreamingResponse, + AsyncLogosResourceWithStreamingResponse, +) +from .matches import ( + MatchesResource, + AsyncMatchesResource, + MatchesResourceWithRawResponse, + AsyncMatchesResourceWithRawResponse, + MatchesResourceWithStreamingResponse, + AsyncMatchesResourceWithStreamingResponse, +) +from .queries import ( + QueriesResource, + AsyncQueriesResource, + QueriesResourceWithRawResponse, + AsyncQueriesResourceWithRawResponse, + QueriesResourceWithStreamingResponse, + AsyncQueriesResourceWithStreamingResponse, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from .logo_matches import ( + LogoMatchesResource, + AsyncLogoMatchesResource, + LogoMatchesResourceWithRawResponse, + AsyncLogoMatchesResourceWithRawResponse, + LogoMatchesResourceWithStreamingResponse, + AsyncLogoMatchesResourceWithStreamingResponse, +) + +__all__ = ["V2Resource", "AsyncV2Resource"] + + +class V2Resource(SyncAPIResource): + @cached_property + def queries(self) -> QueriesResource: + return QueriesResource(self._client) + + @cached_property + def matches(self) -> MatchesResource: + return MatchesResource(self._client) + + @cached_property + def logos(self) -> LogosResource: + return LogosResource(self._client) + + @cached_property + def logo_matches(self) -> LogoMatchesResource: + return LogoMatchesResource(self._client) + + @cached_property + def with_raw_response(self) -> V2ResourceWithRawResponse: + """ + 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 V2ResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> V2ResourceWithStreamingResponse: + """ + 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 V2ResourceWithStreamingResponse(self) + + +class AsyncV2Resource(AsyncAPIResource): + @cached_property + def queries(self) -> AsyncQueriesResource: + return AsyncQueriesResource(self._client) + + @cached_property + def matches(self) -> AsyncMatchesResource: + return AsyncMatchesResource(self._client) + + @cached_property + def logos(self) -> AsyncLogosResource: + return AsyncLogosResource(self._client) + + @cached_property + def logo_matches(self) -> AsyncLogoMatchesResource: + return AsyncLogoMatchesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncV2ResourceWithRawResponse: + """ + 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 AsyncV2ResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncV2ResourceWithStreamingResponse: + """ + 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 AsyncV2ResourceWithStreamingResponse(self) + + +class V2ResourceWithRawResponse: + def __init__(self, v2: V2Resource) -> None: + self._v2 = v2 + + @cached_property + def queries(self) -> QueriesResourceWithRawResponse: + return QueriesResourceWithRawResponse(self._v2.queries) + + @cached_property + def matches(self) -> MatchesResourceWithRawResponse: + return MatchesResourceWithRawResponse(self._v2.matches) + + @cached_property + def logos(self) -> LogosResourceWithRawResponse: + return LogosResourceWithRawResponse(self._v2.logos) + + @cached_property + def logo_matches(self) -> LogoMatchesResourceWithRawResponse: + return LogoMatchesResourceWithRawResponse(self._v2.logo_matches) + + +class AsyncV2ResourceWithRawResponse: + def __init__(self, v2: AsyncV2Resource) -> None: + self._v2 = v2 + + @cached_property + def queries(self) -> AsyncQueriesResourceWithRawResponse: + return AsyncQueriesResourceWithRawResponse(self._v2.queries) + + @cached_property + def matches(self) -> AsyncMatchesResourceWithRawResponse: + return AsyncMatchesResourceWithRawResponse(self._v2.matches) + + @cached_property + def logos(self) -> AsyncLogosResourceWithRawResponse: + return AsyncLogosResourceWithRawResponse(self._v2.logos) + + @cached_property + def logo_matches(self) -> AsyncLogoMatchesResourceWithRawResponse: + return AsyncLogoMatchesResourceWithRawResponse(self._v2.logo_matches) + + +class V2ResourceWithStreamingResponse: + def __init__(self, v2: V2Resource) -> None: + self._v2 = v2 + + @cached_property + def queries(self) -> QueriesResourceWithStreamingResponse: + return QueriesResourceWithStreamingResponse(self._v2.queries) + + @cached_property + def matches(self) -> MatchesResourceWithStreamingResponse: + return MatchesResourceWithStreamingResponse(self._v2.matches) + + @cached_property + def logos(self) -> LogosResourceWithStreamingResponse: + return LogosResourceWithStreamingResponse(self._v2.logos) + + @cached_property + def logo_matches(self) -> LogoMatchesResourceWithStreamingResponse: + return LogoMatchesResourceWithStreamingResponse(self._v2.logo_matches) + + +class AsyncV2ResourceWithStreamingResponse: + def __init__(self, v2: AsyncV2Resource) -> None: + self._v2 = v2 + + @cached_property + def queries(self) -> AsyncQueriesResourceWithStreamingResponse: + return AsyncQueriesResourceWithStreamingResponse(self._v2.queries) + + @cached_property + def matches(self) -> AsyncMatchesResourceWithStreamingResponse: + return AsyncMatchesResourceWithStreamingResponse(self._v2.matches) + + @cached_property + def logos(self) -> AsyncLogosResourceWithStreamingResponse: + return AsyncLogosResourceWithStreamingResponse(self._v2.logos) + + @cached_property + def logo_matches(self) -> AsyncLogoMatchesResourceWithStreamingResponse: + return AsyncLogoMatchesResourceWithStreamingResponse(self._v2.logo_matches) diff --git a/src/cloudflare/resources/browser_rendering/__init__.py b/src/cloudflare/resources/browser_rendering/__init__.py index ca6102ced41..9b2fe570bdb 100644 --- a/src/cloudflare/resources/browser_rendering/__init__.py +++ b/src/cloudflare/resources/browser_rendering/__init__.py @@ -16,6 +16,14 @@ JsonResourceWithStreamingResponse, AsyncJsonResourceWithStreamingResponse, ) +from .crawl import ( + CrawlResource, + AsyncCrawlResource, + CrawlResourceWithRawResponse, + AsyncCrawlResourceWithRawResponse, + CrawlResourceWithStreamingResponse, + AsyncCrawlResourceWithStreamingResponse, +) from .links import ( LinksResource, AsyncLinksResource, @@ -122,6 +130,12 @@ "AsyncMarkdownResourceWithRawResponse", "MarkdownResourceWithStreamingResponse", "AsyncMarkdownResourceWithStreamingResponse", + "CrawlResource", + "AsyncCrawlResource", + "CrawlResourceWithRawResponse", + "AsyncCrawlResourceWithRawResponse", + "CrawlResourceWithStreamingResponse", + "AsyncCrawlResourceWithStreamingResponse", "BrowserRenderingResource", "AsyncBrowserRenderingResource", "BrowserRenderingResourceWithRawResponse", diff --git a/src/cloudflare/resources/browser_rendering/browser_rendering.py b/src/cloudflare/resources/browser_rendering/browser_rendering.py index bee931f57df..608d0c027d3 100644 --- a/src/cloudflare/resources/browser_rendering/browser_rendering.py +++ b/src/cloudflare/resources/browser_rendering/browser_rendering.py @@ -18,6 +18,14 @@ JsonResourceWithStreamingResponse, AsyncJsonResourceWithStreamingResponse, ) +from .crawl import ( + CrawlResource, + AsyncCrawlResource, + CrawlResourceWithRawResponse, + AsyncCrawlResourceWithRawResponse, + CrawlResourceWithStreamingResponse, + AsyncCrawlResourceWithStreamingResponse, +) from .links import ( LinksResource, AsyncLinksResource, @@ -105,6 +113,10 @@ def links(self) -> LinksResource: def markdown(self) -> MarkdownResource: return MarkdownResource(self._client) + @cached_property + def crawl(self) -> CrawlResource: + return CrawlResource(self._client) + @cached_property def with_raw_response(self) -> BrowserRenderingResourceWithRawResponse: """ @@ -158,6 +170,10 @@ def links(self) -> AsyncLinksResource: def markdown(self) -> AsyncMarkdownResource: return AsyncMarkdownResource(self._client) + @cached_property + def crawl(self) -> AsyncCrawlResource: + return AsyncCrawlResource(self._client) + @cached_property def with_raw_response(self) -> AsyncBrowserRenderingResourceWithRawResponse: """ @@ -214,6 +230,10 @@ def links(self) -> LinksResourceWithRawResponse: def markdown(self) -> MarkdownResourceWithRawResponse: return MarkdownResourceWithRawResponse(self._browser_rendering.markdown) + @cached_property + def crawl(self) -> CrawlResourceWithRawResponse: + return CrawlResourceWithRawResponse(self._browser_rendering.crawl) + class AsyncBrowserRenderingResourceWithRawResponse: def __init__(self, browser_rendering: AsyncBrowserRenderingResource) -> None: @@ -251,6 +271,10 @@ def links(self) -> AsyncLinksResourceWithRawResponse: def markdown(self) -> AsyncMarkdownResourceWithRawResponse: return AsyncMarkdownResourceWithRawResponse(self._browser_rendering.markdown) + @cached_property + def crawl(self) -> AsyncCrawlResourceWithRawResponse: + return AsyncCrawlResourceWithRawResponse(self._browser_rendering.crawl) + class BrowserRenderingResourceWithStreamingResponse: def __init__(self, browser_rendering: BrowserRenderingResource) -> None: @@ -288,6 +312,10 @@ def links(self) -> LinksResourceWithStreamingResponse: def markdown(self) -> MarkdownResourceWithStreamingResponse: return MarkdownResourceWithStreamingResponse(self._browser_rendering.markdown) + @cached_property + def crawl(self) -> CrawlResourceWithStreamingResponse: + return CrawlResourceWithStreamingResponse(self._browser_rendering.crawl) + class AsyncBrowserRenderingResourceWithStreamingResponse: def __init__(self, browser_rendering: AsyncBrowserRenderingResource) -> None: @@ -324,3 +352,7 @@ def links(self) -> AsyncLinksResourceWithStreamingResponse: @cached_property def markdown(self) -> AsyncMarkdownResourceWithStreamingResponse: return AsyncMarkdownResourceWithStreamingResponse(self._browser_rendering.markdown) + + @cached_property + def crawl(self) -> AsyncCrawlResourceWithStreamingResponse: + return AsyncCrawlResourceWithStreamingResponse(self._browser_rendering.crawl) diff --git a/src/cloudflare/resources/browser_rendering/crawl.py b/src/cloudflare/resources/browser_rendering/crawl.py new file mode 100644 index 00000000000..1429915bd07 --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/crawl.py @@ -0,0 +1,1115 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Type, Iterable, cast +from typing_extensions import Literal, overload + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.browser_rendering import crawl_get_params, crawl_create_params +from ...types.browser_rendering.crawl_get_response import CrawlGetResponse +from ...types.browser_rendering.crawl_create_response import CrawlCreateResponse +from ...types.browser_rendering.crawl_delete_response import CrawlDeleteResponse + +__all__ = ["CrawlResource", "AsyncCrawlResource"] + + +class CrawlResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> CrawlResourceWithRawResponse: + """ + 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 CrawlResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CrawlResourceWithStreamingResponse: + """ + 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 CrawlResourceWithStreamingResponse(self) + + @overload + def create( + self, + *, + account_id: str, + url: str, + cache_ttl: float | Omit = omit, + action_timeout: float | Omit = omit, + add_script_tag: Iterable[crawl_create_params.Variant0AddScriptTag] | Omit = omit, + add_style_tag: Iterable[crawl_create_params.Variant0AddStyleTag] | Omit = omit, + allow_request_pattern: SequenceNotStr[str] | Omit = omit, + allow_resource_types: List[ + Literal[ + "document", + "stylesheet", + "image", + "media", + "font", + "script", + "texttrack", + "xhr", + "fetch", + "prefetch", + "eventsource", + "websocket", + "manifest", + "signedexchange", + "ping", + "cspviolationreport", + "preflight", + "other", + ] + ] + | Omit = omit, + authenticate: crawl_create_params.Variant0Authenticate | Omit = omit, + best_attempt: bool | Omit = omit, + cookies: Iterable[crawl_create_params.Variant0Cookie] | Omit = omit, + crawl_purposes: List[Literal["search", "ai-input", "ai-train"]] | Omit = omit, + depth: float | Omit = omit, + emulate_media_type: str | Omit = omit, + formats: List[Literal["html", "markdown", "json"]] | Omit = omit, + goto_options: crawl_create_params.Variant0GotoOptions | Omit = omit, + json_options: crawl_create_params.Variant0JsonOptions | Omit = omit, + limit: float | Omit = omit, + max_age: float | Omit = omit, + modified_since: int | Omit = omit, + options: crawl_create_params.Variant0Options | Omit = omit, + reject_request_pattern: SequenceNotStr[str] | Omit = omit, + reject_resource_types: List[ + Literal[ + "document", + "stylesheet", + "image", + "media", + "font", + "script", + "texttrack", + "xhr", + "fetch", + "prefetch", + "eventsource", + "websocket", + "manifest", + "signedexchange", + "ping", + "cspviolationreport", + "preflight", + "other", + ] + ] + | Omit = omit, + render: Literal[True] | Omit = omit, + set_extra_http_headers: Dict[str, str] | Omit = omit, + set_java_script_enabled: bool | Omit = omit, + source: Literal["sitemaps", "links", "all"] | Omit = omit, + viewport: crawl_create_params.Variant0Viewport | Omit = omit, + wait_for_selector: crawl_create_params.Variant0WaitForSelector | Omit = omit, + wait_for_timeout: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """Starts a crawl job for the provided URL and its children. + + Check available + options like `gotoOptions` and `waitFor*` to control page load behaviour. + + Args: + account_id: Account ID. + + url: URL to navigate to, eg. `https://example.com`. + + cache_ttl: Cache TTL default is 5s. Set to 0 to disable. + + action_timeout: The maximum duration allowed for the browser action to complete after the page + has loaded (such as taking screenshots, extracting content, or generating PDFs). + If this time limit is exceeded, the action stops and returns a timeout error. + + add_script_tag: Adds a `