feat(pipelines): add support (#2641)

This commit is contained in:
stainless-app[bot] 2025-05-06 09:47:28 -04:00
parent 415fba0d29
commit c96ed6b2f4
13 changed files with 2299 additions and 4 deletions

View file

@ -1,4 +1,4 @@
configured_endpoints: 1702
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f1801f20f88561f5599c050d86f00eab9cd1f42aae5f927a707a82a3a46f71de.yml
openapi_spec_hash: fd3a16ea4c67e084be680650191a8440
config_hash: 597c14ab32ec8c7121c4e81a6681c26e
configured_endpoints: 1707
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3a98ff8678360cbcb06d9de010a178736703c559351020d019e478cabc36a459.yml
openapi_spec_hash: ccd6a7d73340e32900371f494e0b371e
config_hash: 6513c164fa0cced545d790fbd720f666

21
api.md
View file

@ -9798,3 +9798,24 @@ from cloudflare.types.secrets_store import QuotaGetResponse
Methods:
- <code title="get /accounts/{account_id}/secrets_store/quota">client.secrets_store.quota.<a href="./src/cloudflare/resources/secrets_store/quota.py">get</a>(\*, account_id) -> <a href="./src/cloudflare/types/secrets_store/quota_get_response.py">Optional[QuotaGetResponse]</a></code>
# Pipelines
Types:
```python
from cloudflare.types.pipelines import (
PipelineCreateResponse,
PipelineUpdateResponse,
PipelineListResponse,
PipelineGetResponse,
)
```
Methods:
- <code title="post /accounts/{account_id}/pipelines">client.pipelines.<a href="./src/cloudflare/resources/pipelines.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/pipelines/pipeline_create_params.py">params</a>) -> <a href="./src/cloudflare/types/pipelines/pipeline_create_response.py">PipelineCreateResponse</a></code>
- <code title="put /accounts/{account_id}/pipelines/{pipeline_name}">client.pipelines.<a href="./src/cloudflare/resources/pipelines.py">update</a>(pipeline_name, \*, account_id, \*\*<a href="src/cloudflare/types/pipelines/pipeline_update_params.py">params</a>) -> <a href="./src/cloudflare/types/pipelines/pipeline_update_response.py">PipelineUpdateResponse</a></code>
- <code title="get /accounts/{account_id}/pipelines">client.pipelines.<a href="./src/cloudflare/resources/pipelines.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/pipelines/pipeline_list_params.py">params</a>) -> <a href="./src/cloudflare/types/pipelines/pipeline_list_response.py">PipelineListResponse</a></code>
- <code title="delete /accounts/{account_id}/pipelines/{pipeline_name}">client.pipelines.<a href="./src/cloudflare/resources/pipelines.py">delete</a>(pipeline_name, \*, account_id) -> None</code>
- <code title="get /accounts/{account_id}/pipelines/{pipeline_name}">client.pipelines.<a href="./src/cloudflare/resources/pipelines.py">get</a>(pipeline_name, \*, account_id) -> <a href="./src/cloudflare/types/pipelines/pipeline_get_response.py">PipelineGetResponse</a></code>

View file

@ -73,6 +73,7 @@ if TYPE_CHECKING:
snippets,
spectrum,
hostnames,
pipelines,
registrar,
turnstile,
vectorize,
@ -143,6 +144,7 @@ if TYPE_CHECKING:
from .resources.ssl.ssl import SSLResource, AsyncSSLResource
from .resources.argo.argo import ArgoResource, AsyncArgoResource
from .resources.logs.logs import LogsResource, AsyncLogsResource
from .resources.pipelines import PipelinesResource, AsyncPipelinesResource
from .resources.user.user import UserResource, AsyncUserResource
from .resources.web3.web3 import Web3Resource, AsyncWeb3Resource
from .resources.audit_logs import AuditLogsResource, AsyncAuditLogsResource
@ -894,6 +896,12 @@ class Cloudflare(SyncAPIClient):
return SecretsStoreResource(self)
@cached_property
def pipelines(self) -> PipelinesResource:
from .resources.pipelines import PipelinesResource
return PipelinesResource(self)
@cached_property
def with_raw_response(self) -> CloudflareWithRawResponse:
return CloudflareWithRawResponse(self)
@ -1699,6 +1707,12 @@ class AsyncCloudflare(AsyncAPIClient):
return AsyncSecretsStoreResource(self)
@cached_property
def pipelines(self) -> AsyncPipelinesResource:
from .resources.pipelines import AsyncPipelinesResource
return AsyncPipelinesResource(self)
@cached_property
def with_raw_response(self) -> AsyncCloudflareWithRawResponse:
return AsyncCloudflareWithRawResponse(self)
@ -2439,6 +2453,12 @@ class CloudflareWithRawResponse:
return SecretsStoreResourceWithRawResponse(self._client.secrets_store)
@cached_property
def pipelines(self) -> pipelines.PipelinesResourceWithRawResponse:
from .resources.pipelines import PipelinesResourceWithRawResponse
return PipelinesResourceWithRawResponse(self._client.pipelines)
class AsyncCloudflareWithRawResponse:
_client: AsyncCloudflare
@ -3006,6 +3026,12 @@ class AsyncCloudflareWithRawResponse:
return AsyncSecretsStoreResourceWithRawResponse(self._client.secrets_store)
@cached_property
def pipelines(self) -> pipelines.AsyncPipelinesResourceWithRawResponse:
from .resources.pipelines import AsyncPipelinesResourceWithRawResponse
return AsyncPipelinesResourceWithRawResponse(self._client.pipelines)
class CloudflareWithStreamedResponse:
_client: Cloudflare
@ -3573,6 +3599,12 @@ class CloudflareWithStreamedResponse:
return SecretsStoreResourceWithStreamingResponse(self._client.secrets_store)
@cached_property
def pipelines(self) -> pipelines.PipelinesResourceWithStreamingResponse:
from .resources.pipelines import PipelinesResourceWithStreamingResponse
return PipelinesResourceWithStreamingResponse(self._client.pipelines)
class AsyncCloudflareWithStreamedResponse:
_client: AsyncCloudflare
@ -4150,6 +4182,12 @@ class AsyncCloudflareWithStreamedResponse:
return AsyncSecretsStoreResourceWithStreamingResponse(self._client.secrets_store)
@cached_property
def pipelines(self) -> pipelines.AsyncPipelinesResourceWithStreamingResponse:
from .resources.pipelines import AsyncPipelinesResourceWithStreamingResponse
return AsyncPipelinesResourceWithStreamingResponse(self._client.pipelines)
Client = Cloudflare

View file

@ -0,0 +1,654 @@
# 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 NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
from .._utils import (
maybe_transform,
async_maybe_transform,
)
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import (
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from .._wrappers import ResultWrapper
from .._base_client import make_request_options
from ..types.pipelines import pipeline_list_params, pipeline_create_params, pipeline_update_params
from ..types.pipelines.pipeline_get_response import PipelineGetResponse
from ..types.pipelines.pipeline_list_response import PipelineListResponse
from ..types.pipelines.pipeline_create_response import PipelineCreateResponse
from ..types.pipelines.pipeline_update_response import PipelineUpdateResponse
__all__ = ["PipelinesResource", "AsyncPipelinesResource"]
class PipelinesResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> PipelinesResourceWithRawResponse:
"""
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 PipelinesResourceWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> PipelinesResourceWithStreamingResponse:
"""
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 PipelinesResourceWithStreamingResponse(self)
def create(
self,
*,
account_id: str,
destination: pipeline_create_params.Destination,
name: str,
source: Iterable[pipeline_create_params.Source],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> PipelineCreateResponse:
"""
Create a new Pipeline.
Args:
account_id: Specifies the public ID of the account.
name: Defines the name of Pipeline.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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}/pipelines",
body=maybe_transform(
{
"destination": destination,
"name": name,
"source": source,
},
pipeline_create_params.PipelineCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[PipelineCreateResponse]._unwrapper,
),
cast_to=cast(Type[PipelineCreateResponse], ResultWrapper[PipelineCreateResponse]),
)
def update(
self,
pipeline_name: str,
*,
account_id: str,
destination: pipeline_update_params.Destination,
name: str,
source: Iterable[pipeline_update_params.Source],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> PipelineUpdateResponse:
"""
Update an existing Pipeline.
Args:
account_id: Specifies the public ID of the account.
pipeline_name: Defines the name of Pipeline.
name: Defines the name of Pipeline.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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 pipeline_name:
raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}")
return self._put(
f"/accounts/{account_id}/pipelines/{pipeline_name}",
body=maybe_transform(
{
"destination": destination,
"name": name,
"source": source,
},
pipeline_update_params.PipelineUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[PipelineUpdateResponse]._unwrapper,
),
cast_to=cast(Type[PipelineUpdateResponse], ResultWrapper[PipelineUpdateResponse]),
)
def list(
self,
*,
account_id: str,
page: str | NotGiven = NOT_GIVEN,
per_page: str | NotGiven = NOT_GIVEN,
search: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> PipelineListResponse:
"""
List, filter, and paginate Pipelines in an account.
Args:
account_id: Specifies the public ID of the account.
page: Specifies which page to retrieve.
per_page: Specifies the number of Pipelines per page.
search: Specifies the prefix of Pipeline name to search.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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}/pipelines",
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,
},
pipeline_list_params.PipelineListParams,
),
),
cast_to=PipelineListResponse,
)
def delete(
self,
pipeline_name: str,
*,
account_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
Delete a Pipeline.
Args:
account_id: Specifies the public ID of the account.
pipeline_name: Defines the name of Pipeline.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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 pipeline_name:
raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return self._delete(
f"/accounts/{account_id}/pipelines/{pipeline_name}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=NoneType,
)
def get(
self,
pipeline_name: 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,
) -> PipelineGetResponse:
"""
Get configuration details of a Pipeline.
Args:
account_id: Specifies the public ID of the account.
pipeline_name: Defines the name of Pipeline.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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 pipeline_name:
raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}")
return self._get(
f"/accounts/{account_id}/pipelines/{pipeline_name}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[PipelineGetResponse]._unwrapper,
),
cast_to=cast(Type[PipelineGetResponse], ResultWrapper[PipelineGetResponse]),
)
class AsyncPipelinesResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncPipelinesResourceWithRawResponse:
"""
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 AsyncPipelinesResourceWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncPipelinesResourceWithStreamingResponse:
"""
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 AsyncPipelinesResourceWithStreamingResponse(self)
async def create(
self,
*,
account_id: str,
destination: pipeline_create_params.Destination,
name: str,
source: Iterable[pipeline_create_params.Source],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> PipelineCreateResponse:
"""
Create a new Pipeline.
Args:
account_id: Specifies the public ID of the account.
name: Defines the name of Pipeline.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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}/pipelines",
body=await async_maybe_transform(
{
"destination": destination,
"name": name,
"source": source,
},
pipeline_create_params.PipelineCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[PipelineCreateResponse]._unwrapper,
),
cast_to=cast(Type[PipelineCreateResponse], ResultWrapper[PipelineCreateResponse]),
)
async def update(
self,
pipeline_name: str,
*,
account_id: str,
destination: pipeline_update_params.Destination,
name: str,
source: Iterable[pipeline_update_params.Source],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> PipelineUpdateResponse:
"""
Update an existing Pipeline.
Args:
account_id: Specifies the public ID of the account.
pipeline_name: Defines the name of Pipeline.
name: Defines the name of Pipeline.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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 pipeline_name:
raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}")
return await self._put(
f"/accounts/{account_id}/pipelines/{pipeline_name}",
body=await async_maybe_transform(
{
"destination": destination,
"name": name,
"source": source,
},
pipeline_update_params.PipelineUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[PipelineUpdateResponse]._unwrapper,
),
cast_to=cast(Type[PipelineUpdateResponse], ResultWrapper[PipelineUpdateResponse]),
)
async def list(
self,
*,
account_id: str,
page: str | NotGiven = NOT_GIVEN,
per_page: str | NotGiven = NOT_GIVEN,
search: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> PipelineListResponse:
"""
List, filter, and paginate Pipelines in an account.
Args:
account_id: Specifies the public ID of the account.
page: Specifies which page to retrieve.
per_page: Specifies the number of Pipelines per page.
search: Specifies the prefix of Pipeline name to search.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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}/pipelines",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{
"page": page,
"per_page": per_page,
"search": search,
},
pipeline_list_params.PipelineListParams,
),
),
cast_to=PipelineListResponse,
)
async def delete(
self,
pipeline_name: str,
*,
account_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
Delete a Pipeline.
Args:
account_id: Specifies the public ID of the account.
pipeline_name: Defines the name of Pipeline.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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 pipeline_name:
raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return await self._delete(
f"/accounts/{account_id}/pipelines/{pipeline_name}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=NoneType,
)
async def get(
self,
pipeline_name: 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,
) -> PipelineGetResponse:
"""
Get configuration details of a Pipeline.
Args:
account_id: Specifies the public ID of the account.
pipeline_name: Defines the name of Pipeline.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for 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 pipeline_name:
raise ValueError(f"Expected a non-empty value for `pipeline_name` but received {pipeline_name!r}")
return await self._get(
f"/accounts/{account_id}/pipelines/{pipeline_name}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[PipelineGetResponse]._unwrapper,
),
cast_to=cast(Type[PipelineGetResponse], ResultWrapper[PipelineGetResponse]),
)
class PipelinesResourceWithRawResponse:
def __init__(self, pipelines: PipelinesResource) -> None:
self._pipelines = pipelines
self.create = to_raw_response_wrapper(
pipelines.create,
)
self.update = to_raw_response_wrapper(
pipelines.update,
)
self.list = to_raw_response_wrapper(
pipelines.list,
)
self.delete = to_raw_response_wrapper(
pipelines.delete,
)
self.get = to_raw_response_wrapper(
pipelines.get,
)
class AsyncPipelinesResourceWithRawResponse:
def __init__(self, pipelines: AsyncPipelinesResource) -> None:
self._pipelines = pipelines
self.create = async_to_raw_response_wrapper(
pipelines.create,
)
self.update = async_to_raw_response_wrapper(
pipelines.update,
)
self.list = async_to_raw_response_wrapper(
pipelines.list,
)
self.delete = async_to_raw_response_wrapper(
pipelines.delete,
)
self.get = async_to_raw_response_wrapper(
pipelines.get,
)
class PipelinesResourceWithStreamingResponse:
def __init__(self, pipelines: PipelinesResource) -> None:
self._pipelines = pipelines
self.create = to_streamed_response_wrapper(
pipelines.create,
)
self.update = to_streamed_response_wrapper(
pipelines.update,
)
self.list = to_streamed_response_wrapper(
pipelines.list,
)
self.delete = to_streamed_response_wrapper(
pipelines.delete,
)
self.get = to_streamed_response_wrapper(
pipelines.get,
)
class AsyncPipelinesResourceWithStreamingResponse:
def __init__(self, pipelines: AsyncPipelinesResource) -> None:
self._pipelines = pipelines
self.create = async_to_streamed_response_wrapper(
pipelines.create,
)
self.update = async_to_streamed_response_wrapper(
pipelines.update,
)
self.list = async_to_streamed_response_wrapper(
pipelines.list,
)
self.delete = async_to_streamed_response_wrapper(
pipelines.delete,
)
self.get = async_to_streamed_response_wrapper(
pipelines.get,
)

View file

@ -0,0 +1,11 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from .pipeline_list_params import PipelineListParams as PipelineListParams
from .pipeline_get_response import PipelineGetResponse as PipelineGetResponse
from .pipeline_create_params import PipelineCreateParams as PipelineCreateParams
from .pipeline_list_response import PipelineListResponse as PipelineListResponse
from .pipeline_update_params import PipelineUpdateParams as PipelineUpdateParams
from .pipeline_create_response import PipelineCreateResponse as PipelineCreateResponse
from .pipeline_update_response import PipelineUpdateResponse as PipelineUpdateResponse

View file

@ -0,0 +1,117 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import List, Union, Iterable
from typing_extensions import Literal, Required, TypeAlias, TypedDict
__all__ = [
"PipelineCreateParams",
"Destination",
"DestinationBatch",
"DestinationCompression",
"DestinationCredentials",
"DestinationPath",
"Source",
"SourceWorkersPipelinesWorkersPipelinesHTTPSource",
"SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS",
"SourceWorkersPipelinesWorkersPipelinesBindingSource",
]
class PipelineCreateParams(TypedDict, total=False):
account_id: Required[str]
"""Specifies the public ID of the account."""
destination: Required[Destination]
name: Required[str]
"""Defines the name of Pipeline."""
source: Required[Iterable[Source]]
class DestinationBatch(TypedDict, total=False):
max_bytes: int
"""Specifies rough maximum size of files."""
max_duration_s: float
"""Specifies duration to wait to aggregate batches files."""
max_rows: int
"""Specifies rough maximum number of rows per file."""
class DestinationCompression(TypedDict, total=False):
type: Literal["none", "gzip", "deflate"]
"""Specifies the desired compression algorithm and format."""
class DestinationCredentials(TypedDict, total=False):
access_key_id: Required[str]
"""Specifies the R2 Bucket Access Key Id."""
endpoint: Required[str]
"""Specifies the R2 Endpoint."""
secret_access_key: Required[str]
"""Specifies the R2 Bucket Secret Access Key."""
class DestinationPath(TypedDict, total=False):
bucket: Required[str]
"""Specifies the R2 Bucket to store files."""
filename: str
"""Specifies the name pattern to for individual data files."""
filepath: str
"""Specifies the name pattern for directory."""
prefix: str
"""Specifies the base directory within the bucket."""
class Destination(TypedDict, total=False):
batch: Required[DestinationBatch]
compression: Required[DestinationCompression]
credentials: Required[DestinationCredentials]
format: Required[Literal["json"]]
"""Specifies the format of data to deliver."""
path: Required[DestinationPath]
type: Required[Literal["r2"]]
"""Specifies the type of destination."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS(TypedDict, total=False):
origins: List[str]
"""Specifies allowed origins to allow Cross Origin HTTP Requests."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSource(TypedDict, total=False):
format: Required[Literal["json"]]
"""Specifies the format of source data."""
type: Required[str]
authentication: bool
"""Specifies authentication is required to send to this Pipeline."""
cors: SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS
class SourceWorkersPipelinesWorkersPipelinesBindingSource(TypedDict, total=False):
format: Required[Literal["json"]]
"""Specifies the format of source data."""
type: Required[str]
Source: TypeAlias = Union[
SourceWorkersPipelinesWorkersPipelinesHTTPSource, SourceWorkersPipelinesWorkersPipelinesBindingSource
]

View file

@ -0,0 +1,109 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Union, Optional
from typing_extensions import Literal, TypeAlias
from ..._models import BaseModel
__all__ = [
"PipelineCreateResponse",
"Destination",
"DestinationBatch",
"DestinationCompression",
"DestinationPath",
"Source",
"SourceWorkersPipelinesWorkersPipelinesHTTPSource",
"SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS",
"SourceWorkersPipelinesWorkersPipelinesBindingSource",
]
class DestinationBatch(BaseModel):
max_bytes: int
"""Specifies rough maximum size of files."""
max_duration_s: float
"""Specifies duration to wait to aggregate batches files."""
max_rows: int
"""Specifies rough maximum number of rows per file."""
class DestinationCompression(BaseModel):
type: Literal["none", "gzip", "deflate"]
"""Specifies the desired compression algorithm and format."""
class DestinationPath(BaseModel):
bucket: str
"""Specifies the R2 Bucket to store files."""
filename: Optional[str] = None
"""Specifies the name pattern to for individual data files."""
filepath: Optional[str] = None
"""Specifies the name pattern for directory."""
prefix: Optional[str] = None
"""Specifies the base directory within the bucket."""
class Destination(BaseModel):
batch: DestinationBatch
compression: DestinationCompression
format: Literal["json"]
"""Specifies the format of data to deliver."""
path: DestinationPath
type: Literal["r2"]
"""Specifies the type of destination."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS(BaseModel):
origins: Optional[List[str]] = None
"""Specifies allowed origins to allow Cross Origin HTTP Requests."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSource(BaseModel):
format: Literal["json"]
"""Specifies the format of source data."""
type: str
authentication: Optional[bool] = None
"""Specifies authentication is required to send to this Pipeline."""
cors: Optional[SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS] = None
class SourceWorkersPipelinesWorkersPipelinesBindingSource(BaseModel):
format: Literal["json"]
"""Specifies the format of source data."""
type: str
Source: TypeAlias = Union[
SourceWorkersPipelinesWorkersPipelinesHTTPSource, SourceWorkersPipelinesWorkersPipelinesBindingSource
]
class PipelineCreateResponse(BaseModel):
id: str
"""Specifies the Pipeline identifier."""
destination: Destination
endpoint: str
"""Indicates the endpoint URL to send traffic."""
name: str
"""Defines the name of Pipeline."""
source: List[Source]
version: float
"""Indicates the version number of last saved configuration."""

View file

@ -0,0 +1,109 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Union, Optional
from typing_extensions import Literal, TypeAlias
from ..._models import BaseModel
__all__ = [
"PipelineGetResponse",
"Destination",
"DestinationBatch",
"DestinationCompression",
"DestinationPath",
"Source",
"SourceWorkersPipelinesWorkersPipelinesHTTPSource",
"SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS",
"SourceWorkersPipelinesWorkersPipelinesBindingSource",
]
class DestinationBatch(BaseModel):
max_bytes: int
"""Specifies rough maximum size of files."""
max_duration_s: float
"""Specifies duration to wait to aggregate batches files."""
max_rows: int
"""Specifies rough maximum number of rows per file."""
class DestinationCompression(BaseModel):
type: Literal["none", "gzip", "deflate"]
"""Specifies the desired compression algorithm and format."""
class DestinationPath(BaseModel):
bucket: str
"""Specifies the R2 Bucket to store files."""
filename: Optional[str] = None
"""Specifies the name pattern to for individual data files."""
filepath: Optional[str] = None
"""Specifies the name pattern for directory."""
prefix: Optional[str] = None
"""Specifies the base directory within the bucket."""
class Destination(BaseModel):
batch: DestinationBatch
compression: DestinationCompression
format: Literal["json"]
"""Specifies the format of data to deliver."""
path: DestinationPath
type: Literal["r2"]
"""Specifies the type of destination."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS(BaseModel):
origins: Optional[List[str]] = None
"""Specifies allowed origins to allow Cross Origin HTTP Requests."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSource(BaseModel):
format: Literal["json"]
"""Specifies the format of source data."""
type: str
authentication: Optional[bool] = None
"""Specifies authentication is required to send to this Pipeline."""
cors: Optional[SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS] = None
class SourceWorkersPipelinesWorkersPipelinesBindingSource(BaseModel):
format: Literal["json"]
"""Specifies the format of source data."""
type: str
Source: TypeAlias = Union[
SourceWorkersPipelinesWorkersPipelinesHTTPSource, SourceWorkersPipelinesWorkersPipelinesBindingSource
]
class PipelineGetResponse(BaseModel):
id: str
"""Specifies the Pipeline identifier."""
destination: Destination
endpoint: str
"""Indicates the endpoint URL to send traffic."""
name: str
"""Defines the name of Pipeline."""
source: List[Source]
version: float
"""Indicates the version number of last saved configuration."""

View file

@ -0,0 +1,21 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Required, TypedDict
__all__ = ["PipelineListParams"]
class PipelineListParams(TypedDict, total=False):
account_id: Required[str]
"""Specifies the public ID of the account."""
page: str
"""Specifies which page to retrieve."""
per_page: str
"""Specifies the number of Pipelines per page."""
search: str
"""Specifies the prefix of Pipeline name to search."""

View file

@ -0,0 +1,134 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Union, Optional
from typing_extensions import Literal, TypeAlias
from ..._models import BaseModel
__all__ = [
"PipelineListResponse",
"ResultInfo",
"Result",
"ResultDestination",
"ResultDestinationBatch",
"ResultDestinationCompression",
"ResultDestinationPath",
"ResultSource",
"ResultSourceWorkersPipelinesWorkersPipelinesHTTPSource",
"ResultSourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS",
"ResultSourceWorkersPipelinesWorkersPipelinesBindingSource",
]
class ResultInfo(BaseModel):
count: float
"""Indicates the number of items on current page."""
page: float
"""Indicates the current page number."""
per_page: float
"""Indicates the number of items per page."""
total_count: float
"""Indicates the total number of items."""
class ResultDestinationBatch(BaseModel):
max_bytes: int
"""Specifies rough maximum size of files."""
max_duration_s: float
"""Specifies duration to wait to aggregate batches files."""
max_rows: int
"""Specifies rough maximum number of rows per file."""
class ResultDestinationCompression(BaseModel):
type: Literal["none", "gzip", "deflate"]
"""Specifies the desired compression algorithm and format."""
class ResultDestinationPath(BaseModel):
bucket: str
"""Specifies the R2 Bucket to store files."""
filename: Optional[str] = None
"""Specifies the name pattern to for individual data files."""
filepath: Optional[str] = None
"""Specifies the name pattern for directory."""
prefix: Optional[str] = None
"""Specifies the base directory within the bucket."""
class ResultDestination(BaseModel):
batch: ResultDestinationBatch
compression: ResultDestinationCompression
format: Literal["json"]
"""Specifies the format of data to deliver."""
path: ResultDestinationPath
type: Literal["r2"]
"""Specifies the type of destination."""
class ResultSourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS(BaseModel):
origins: Optional[List[str]] = None
"""Specifies allowed origins to allow Cross Origin HTTP Requests."""
class ResultSourceWorkersPipelinesWorkersPipelinesHTTPSource(BaseModel):
format: Literal["json"]
"""Specifies the format of source data."""
type: str
authentication: Optional[bool] = None
"""Specifies authentication is required to send to this Pipeline."""
cors: Optional[ResultSourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS] = None
class ResultSourceWorkersPipelinesWorkersPipelinesBindingSource(BaseModel):
format: Literal["json"]
"""Specifies the format of source data."""
type: str
ResultSource: TypeAlias = Union[
ResultSourceWorkersPipelinesWorkersPipelinesHTTPSource, ResultSourceWorkersPipelinesWorkersPipelinesBindingSource
]
class Result(BaseModel):
id: str
"""Specifies the Pipeline identifier."""
destination: ResultDestination
endpoint: str
"""Indicates the endpoint URL to send traffic."""
name: str
"""Defines the name of Pipeline."""
source: List[ResultSource]
version: float
"""Indicates the version number of last saved configuration."""
class PipelineListResponse(BaseModel):
result_info: ResultInfo
results: List[Result]
success: bool
"""Indicates whether the API call was successful."""

View file

@ -0,0 +1,117 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import List, Union, Iterable
from typing_extensions import Literal, Required, TypeAlias, TypedDict
__all__ = [
"PipelineUpdateParams",
"Destination",
"DestinationBatch",
"DestinationCompression",
"DestinationPath",
"DestinationCredentials",
"Source",
"SourceWorkersPipelinesWorkersPipelinesHTTPSource",
"SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS",
"SourceWorkersPipelinesWorkersPipelinesBindingSource",
]
class PipelineUpdateParams(TypedDict, total=False):
account_id: Required[str]
"""Specifies the public ID of the account."""
destination: Required[Destination]
name: Required[str]
"""Defines the name of Pipeline."""
source: Required[Iterable[Source]]
class DestinationBatch(TypedDict, total=False):
max_bytes: int
"""Specifies rough maximum size of files."""
max_duration_s: float
"""Specifies duration to wait to aggregate batches files."""
max_rows: int
"""Specifies rough maximum number of rows per file."""
class DestinationCompression(TypedDict, total=False):
type: Literal["none", "gzip", "deflate"]
"""Specifies the desired compression algorithm and format."""
class DestinationPath(TypedDict, total=False):
bucket: Required[str]
"""Specifies the R2 Bucket to store files."""
filename: str
"""Specifies the name pattern to for individual data files."""
filepath: str
"""Specifies the name pattern for directory."""
prefix: str
"""Specifies the base directory within the bucket."""
class DestinationCredentials(TypedDict, total=False):
access_key_id: Required[str]
"""Specifies the R2 Bucket Access Key Id."""
endpoint: Required[str]
"""Specifies the R2 Endpoint."""
secret_access_key: Required[str]
"""Specifies the R2 Bucket Secret Access Key."""
class Destination(TypedDict, total=False):
batch: Required[DestinationBatch]
compression: Required[DestinationCompression]
format: Required[Literal["json"]]
"""Specifies the format of data to deliver."""
path: Required[DestinationPath]
type: Required[Literal["r2"]]
"""Specifies the type of destination."""
credentials: DestinationCredentials
class SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS(TypedDict, total=False):
origins: List[str]
"""Specifies allowed origins to allow Cross Origin HTTP Requests."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSource(TypedDict, total=False):
format: Required[Literal["json"]]
"""Specifies the format of source data."""
type: Required[str]
authentication: bool
"""Specifies authentication is required to send to this Pipeline."""
cors: SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS
class SourceWorkersPipelinesWorkersPipelinesBindingSource(TypedDict, total=False):
format: Required[Literal["json"]]
"""Specifies the format of source data."""
type: Required[str]
Source: TypeAlias = Union[
SourceWorkersPipelinesWorkersPipelinesHTTPSource, SourceWorkersPipelinesWorkersPipelinesBindingSource
]

View file

@ -0,0 +1,109 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Union, Optional
from typing_extensions import Literal, TypeAlias
from ..._models import BaseModel
__all__ = [
"PipelineUpdateResponse",
"Destination",
"DestinationBatch",
"DestinationCompression",
"DestinationPath",
"Source",
"SourceWorkersPipelinesWorkersPipelinesHTTPSource",
"SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS",
"SourceWorkersPipelinesWorkersPipelinesBindingSource",
]
class DestinationBatch(BaseModel):
max_bytes: int
"""Specifies rough maximum size of files."""
max_duration_s: float
"""Specifies duration to wait to aggregate batches files."""
max_rows: int
"""Specifies rough maximum number of rows per file."""
class DestinationCompression(BaseModel):
type: Literal["none", "gzip", "deflate"]
"""Specifies the desired compression algorithm and format."""
class DestinationPath(BaseModel):
bucket: str
"""Specifies the R2 Bucket to store files."""
filename: Optional[str] = None
"""Specifies the name pattern to for individual data files."""
filepath: Optional[str] = None
"""Specifies the name pattern for directory."""
prefix: Optional[str] = None
"""Specifies the base directory within the bucket."""
class Destination(BaseModel):
batch: DestinationBatch
compression: DestinationCompression
format: Literal["json"]
"""Specifies the format of data to deliver."""
path: DestinationPath
type: Literal["r2"]
"""Specifies the type of destination."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS(BaseModel):
origins: Optional[List[str]] = None
"""Specifies allowed origins to allow Cross Origin HTTP Requests."""
class SourceWorkersPipelinesWorkersPipelinesHTTPSource(BaseModel):
format: Literal["json"]
"""Specifies the format of source data."""
type: str
authentication: Optional[bool] = None
"""Specifies authentication is required to send to this Pipeline."""
cors: Optional[SourceWorkersPipelinesWorkersPipelinesHTTPSourceCORS] = None
class SourceWorkersPipelinesWorkersPipelinesBindingSource(BaseModel):
format: Literal["json"]
"""Specifies the format of source data."""
type: str
Source: TypeAlias = Union[
SourceWorkersPipelinesWorkersPipelinesHTTPSource, SourceWorkersPipelinesWorkersPipelinesBindingSource
]
class PipelineUpdateResponse(BaseModel):
id: str
"""Specifies the Pipeline identifier."""
destination: Destination
endpoint: str
"""Indicates the endpoint URL to send traffic."""
name: str
"""Defines the name of Pipeline."""
source: List[Source]
version: float
"""Indicates the version number of last saved configuration."""

View file

@ -0,0 +1,855 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
import os
from typing import Any, cast
import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.types.pipelines import (
PipelineGetResponse,
PipelineListResponse,
PipelineCreateResponse,
PipelineUpdateResponse,
)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
class TestPipelines:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_create(self, client: Cloudflare) -> None:
pipeline = client.pipelines.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
assert_matches_type(PipelineCreateResponse, pipeline, path=["response"])
@parametrize
def test_raw_response_create(self, client: Cloudflare) -> None:
response = client.pipelines.with_raw_response.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert_matches_type(PipelineCreateResponse, pipeline, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Cloudflare) -> None:
with client.pipelines.with_streaming_response.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert_matches_type(PipelineCreateResponse, pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_create(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.pipelines.with_raw_response.create(
account_id="",
destination={
"batch": {},
"compression": {},
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
@parametrize
def test_method_update(self, client: Cloudflare) -> None:
pipeline = client.pipelines.update(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
assert_matches_type(PipelineUpdateResponse, pipeline, path=["response"])
@parametrize
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
pipeline = client.pipelines.update(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {
"max_bytes": 1000,
"max_duration_s": 0.25,
"max_rows": 100,
},
"compression": {"type": "gzip"},
"format": "json",
"path": {
"bucket": "bucket",
"filename": "${slug}${extension}",
"filepath": "${date}/${hour}",
"prefix": "base",
},
"type": "r2",
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
"authentication": True,
"cors": {"origins": ["*"]},
}
],
)
assert_matches_type(PipelineUpdateResponse, pipeline, path=["response"])
@parametrize
def test_raw_response_update(self, client: Cloudflare) -> None:
response = client.pipelines.with_raw_response.update(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert_matches_type(PipelineUpdateResponse, pipeline, path=["response"])
@parametrize
def test_streaming_response_update(self, client: Cloudflare) -> None:
with client.pipelines.with_streaming_response.update(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert_matches_type(PipelineUpdateResponse, pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_update(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.pipelines.with_raw_response.update(
pipeline_name="sample_pipeline",
account_id="",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `pipeline_name` but received ''"):
client.pipelines.with_raw_response.update(
pipeline_name="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
@parametrize
def test_method_list(self, client: Cloudflare) -> None:
pipeline = client.pipelines.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(PipelineListResponse, pipeline, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
pipeline = client.pipelines.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
page="page",
per_page="per_page",
search="search",
)
assert_matches_type(PipelineListResponse, pipeline, path=["response"])
@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
response = client.pipelines.with_raw_response.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert_matches_type(PipelineListResponse, pipeline, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
with client.pipelines.with_streaming_response.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert_matches_type(PipelineListResponse, pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_list(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.pipelines.with_raw_response.list(
account_id="",
)
@parametrize
def test_method_delete(self, client: Cloudflare) -> None:
pipeline = client.pipelines.delete(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert pipeline is None
@parametrize
def test_raw_response_delete(self, client: Cloudflare) -> None:
response = client.pipelines.with_raw_response.delete(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert pipeline is None
@parametrize
def test_streaming_response_delete(self, client: Cloudflare) -> None:
with client.pipelines.with_streaming_response.delete(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert pipeline is None
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_delete(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.pipelines.with_raw_response.delete(
pipeline_name="sample_pipeline",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `pipeline_name` but received ''"):
client.pipelines.with_raw_response.delete(
pipeline_name="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@parametrize
def test_method_get(self, client: Cloudflare) -> None:
pipeline = client.pipelines.get(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(PipelineGetResponse, pipeline, path=["response"])
@parametrize
def test_raw_response_get(self, client: Cloudflare) -> None:
response = client.pipelines.with_raw_response.get(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert_matches_type(PipelineGetResponse, pipeline, path=["response"])
@parametrize
def test_streaming_response_get(self, client: Cloudflare) -> None:
with client.pipelines.with_streaming_response.get(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = response.parse()
assert_matches_type(PipelineGetResponse, pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_get(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.pipelines.with_raw_response.get(
pipeline_name="sample_pipeline",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `pipeline_name` but received ''"):
client.pipelines.with_raw_response.get(
pipeline_name="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
class TestAsyncPipelines:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
pipeline = await async_client.pipelines.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
assert_matches_type(PipelineCreateResponse, pipeline, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
response = await async_client.pipelines.with_raw_response.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert_matches_type(PipelineCreateResponse, pipeline, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
async with async_client.pipelines.with_streaming_response.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert_matches_type(PipelineCreateResponse, pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.pipelines.with_raw_response.create(
account_id="",
destination={
"batch": {},
"compression": {},
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
@parametrize
async def test_method_update(self, async_client: AsyncCloudflare) -> None:
pipeline = await async_client.pipelines.update(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
assert_matches_type(PipelineUpdateResponse, pipeline, path=["response"])
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
pipeline = await async_client.pipelines.update(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {
"max_bytes": 1000,
"max_duration_s": 0.25,
"max_rows": 100,
},
"compression": {"type": "gzip"},
"format": "json",
"path": {
"bucket": "bucket",
"filename": "${slug}${extension}",
"filepath": "${date}/${hour}",
"prefix": "base",
},
"type": "r2",
"credentials": {
"access_key_id": "<access key id>",
"endpoint": "https://123f8a8258064ed892a347f173372359.r2.cloudflarestorage.com",
"secret_access_key": "<secret key>",
},
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
"authentication": True,
"cors": {"origins": ["*"]},
}
],
)
assert_matches_type(PipelineUpdateResponse, pipeline, path=["response"])
@parametrize
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
response = await async_client.pipelines.with_raw_response.update(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert_matches_type(PipelineUpdateResponse, pipeline, path=["response"])
@parametrize
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
async with async_client.pipelines.with_streaming_response.update(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert_matches_type(PipelineUpdateResponse, pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.pipelines.with_raw_response.update(
pipeline_name="sample_pipeline",
account_id="",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `pipeline_name` but received ''"):
await async_client.pipelines.with_raw_response.update(
pipeline_name="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
destination={
"batch": {},
"compression": {},
"format": "json",
"path": {"bucket": "bucket"},
"type": "r2",
},
name="sample_pipeline",
source=[
{
"format": "json",
"type": "type",
}
],
)
@parametrize
async def test_method_list(self, async_client: AsyncCloudflare) -> None:
pipeline = await async_client.pipelines.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(PipelineListResponse, pipeline, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
pipeline = await async_client.pipelines.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
page="page",
per_page="per_page",
search="search",
)
assert_matches_type(PipelineListResponse, pipeline, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
response = await async_client.pipelines.with_raw_response.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert_matches_type(PipelineListResponse, pipeline, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
async with async_client.pipelines.with_streaming_response.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert_matches_type(PipelineListResponse, pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.pipelines.with_raw_response.list(
account_id="",
)
@parametrize
async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
pipeline = await async_client.pipelines.delete(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert pipeline is None
@parametrize
async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
response = await async_client.pipelines.with_raw_response.delete(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert pipeline is None
@parametrize
async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
async with async_client.pipelines.with_streaming_response.delete(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert pipeline is None
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.pipelines.with_raw_response.delete(
pipeline_name="sample_pipeline",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `pipeline_name` but received ''"):
await async_client.pipelines.with_raw_response.delete(
pipeline_name="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@parametrize
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
pipeline = await async_client.pipelines.get(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(PipelineGetResponse, pipeline, path=["response"])
@parametrize
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
response = await async_client.pipelines.with_raw_response.get(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert_matches_type(PipelineGetResponse, pipeline, path=["response"])
@parametrize
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
async with async_client.pipelines.with_streaming_response.get(
pipeline_name="sample_pipeline",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
pipeline = await response.parse()
assert_matches_type(PipelineGetResponse, pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.pipelines.with_raw_response.get(
pipeline_name="sample_pipeline",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `pipeline_name` but received ''"):
await async_client.pipelines.with_raw_response.get(
pipeline_name="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)