-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(r2_bucket): add
cors
support (#2196)
1 parent
2de0fb0
commit 8ed5f71
Showing
9 changed files
with
1,029 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
configured_endpoints: 1448 | ||
configured_endpoints: 1451 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4acaaed718bd08d16e3866d5ad032fbf2bbfeb978df2cf5164edb81fe41e4f89.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
from typing import List, Optional | ||
from typing_extensions import Literal | ||
|
||
from pydantic import Field as FieldInfo | ||
|
||
from ...._models import BaseModel | ||
|
||
__all__ = ["CORSGetResponse", "Rule", "RuleAllowed"] | ||
|
||
|
||
class RuleAllowed(BaseModel): | ||
methods: List[Literal["GET", "PUT", "POST", "DELETE", "HEAD"]] | ||
""" | ||
Specifies the value for the Access-Control-Allow-Methods header R2 sets when | ||
requesting objects in a bucket from a browser. | ||
""" | ||
|
||
origins: List[str] | ||
""" | ||
Specifies the value for the Access-Control-Allow-Origin header R2 sets when | ||
requesting objects in a bucket from a browser. | ||
""" | ||
|
||
headers: Optional[List[str]] = None | ||
""" | ||
Specifies the value for the Access-Control-Allow-Headers header R2 sets when | ||
requesting objects in this bucket from a browser. Cross-origin requests that | ||
include custom headers (e.g. x-user-id) should specify these headers as | ||
AllowedHeaders. | ||
""" | ||
|
||
|
||
class Rule(BaseModel): | ||
allowed: RuleAllowed | ||
"""Object specifying allowed origins, methods and headers for this CORS rule.""" | ||
|
||
id: Optional[str] = None | ||
"""Identifier for this rule""" | ||
|
||
expose_headers: Optional[List[str]] = FieldInfo(alias="exposeHeaders", default=None) | ||
""" | ||
Specifies the headers that can be exposed back, and accessed by, the JavaScript | ||
making the cross-origin request. If you need to access headers beyond the | ||
safelisted response headers, such as Content-Encoding or cf-cache-status, you | ||
must specify it here. | ||
""" | ||
|
||
max_age_seconds: Optional[float] = FieldInfo(alias="maxAgeSeconds", default=None) | ||
""" | ||
Specifies the amount of time (in seconds) browsers are allowed to cache CORS | ||
preflight responses. Browsers may limit this to 2 hours or less, even if the | ||
maximum value (86400) is specified. | ||
""" | ||
|
||
|
||
class CORSGetResponse(BaseModel): | ||
rules: Optional[List[Rule]] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
from __future__ import annotations | ||
|
||
from typing import List, Iterable | ||
from typing_extensions import Literal, Required, Annotated, TypedDict | ||
|
||
from ...._utils import PropertyInfo | ||
|
||
__all__ = ["CORSUpdateParams", "Rule", "RuleAllowed"] | ||
|
||
|
||
class CORSUpdateParams(TypedDict, total=False): | ||
account_id: Required[str] | ||
"""Account ID""" | ||
|
||
rules: Iterable[Rule] | ||
|
||
cf_r2_jurisdiction: Annotated[Literal["default", "eu", "fedramp"], PropertyInfo(alias="cf-r2-jurisdiction")] | ||
"""The bucket jurisdiction""" | ||
|
||
|
||
class RuleAllowed(TypedDict, total=False): | ||
methods: Required[List[Literal["GET", "PUT", "POST", "DELETE", "HEAD"]]] | ||
""" | ||
Specifies the value for the Access-Control-Allow-Methods header R2 sets when | ||
requesting objects in a bucket from a browser. | ||
""" | ||
|
||
origins: Required[List[str]] | ||
""" | ||
Specifies the value for the Access-Control-Allow-Origin header R2 sets when | ||
requesting objects in a bucket from a browser. | ||
""" | ||
|
||
headers: List[str] | ||
""" | ||
Specifies the value for the Access-Control-Allow-Headers header R2 sets when | ||
requesting objects in this bucket from a browser. Cross-origin requests that | ||
include custom headers (e.g. x-user-id) should specify these headers as | ||
AllowedHeaders. | ||
""" | ||
|
||
|
||
class Rule(TypedDict, total=False): | ||
allowed: Required[RuleAllowed] | ||
"""Object specifying allowed origins, methods and headers for this CORS rule.""" | ||
|
||
id: str | ||
"""Identifier for this rule""" | ||
|
||
expose_headers: Annotated[List[str], PropertyInfo(alias="exposeHeaders")] | ||
""" | ||
Specifies the headers that can be exposed back, and accessed by, the JavaScript | ||
making the cross-origin request. If you need to access headers beyond the | ||
safelisted response headers, such as Content-Encoding or cf-cache-status, you | ||
must specify it here. | ||
""" | ||
|
||
max_age_seconds: Annotated[float, PropertyInfo(alias="maxAgeSeconds")] | ||
""" | ||
Specifies the amount of time (in seconds) browsers are allowed to cache CORS | ||
preflight responses. Browsers may limit this to 2 hours or less, even if the | ||
maximum value (86400) is specified. | ||
""" |
Large diffs are not rendered by default.
Oops, something went wrong.