diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21d8baf0..30235252 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: - name: Get GitHub OIDC Token if: github.repository == 'stainless-sdks/gcore-python' id: github-oidc - uses: actions/github-script@v6 + uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 554e34bb..f81bf992 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.30.0" + ".": "0.31.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index f6bc2e9b..f736874a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 645 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-2d64161889a53046ca5e593a772328a5290246c3d74f8c07fed1037feae1bdbc.yml -openapi_spec_hash: 2360d25764d74e6972cf600fcd20fd4e -config_hash: e9e5b750687e9071d8b606963f0ffd6d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-58d9afa7f8342ead022bd8fa12bb8abbeb9c0fb1e16f052ee6c4a59fae373e27.yml +openapi_spec_hash: 2ae4db03cfc907be71d44288503838d7 +config_hash: 8d4711ed72633b7443249124a49781da diff --git a/CHANGELOG.md b/CHANGELOG.md index 1511c56c..3fbb5e5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 0.31.0 (2026-01-30) + +Full Changelog: [v0.30.0...v0.31.0](https://github.com/G-Core/gcore-python/compare/v0.30.0...v0.31.0) + +### ⚠ BREAKING CHANGES + +* **cdn:** rename resource to cdn_resource +* **api:** change type casing from Cdn* to CDN* + +### Features + +* **api:** aggregated API specs update ([cd35cbf](https://github.com/G-Core/gcore-python/commit/cd35cbf266cf598045a8a4f8ebf3cf7cd8340092)) +* **api:** aggregated API specs update ([a7076d0](https://github.com/G-Core/gcore-python/commit/a7076d04fa78e4ea71b148ef8c10d0013536e904)) +* **api:** manual upload of aggregated API specs ([47734d2](https://github.com/G-Core/gcore-python/commit/47734d2b4fcd22875d2ec80b2b0453600b912eca)) +* **api:** refactor(cdn)!: change type casing from Cdn* to CDN* ([4ea3f5c](https://github.com/G-Core/gcore-python/commit/4ea3f5c23afe085bf5c8b25dadfb1bcd1899edfe)) +* **client:** add custom JSON encoder for extended type support ([b0c58f9](https://github.com/G-Core/gcore-python/commit/b0c58f9f042c3e67b63d99bded8179c943d29711)) + + +### Bug Fixes + +* **client:** internal references to CDN types ([13f5d35](https://github.com/G-Core/gcore-python/commit/13f5d3512b170ee9db3757768cbafb44831c61c4)) + + +### Chores + +* **ci:** upgrade `actions/github-script` ([a2328c0](https://github.com/G-Core/gcore-python/commit/a2328c02b6d94f8af8cdeb7dbc72d81f1e2d17d0)) + + +### Refactors + +* **cdn:** rename resource to cdn_resource ([aff2220](https://github.com/G-Core/gcore-python/commit/aff2220ee6c6d14566007e54136de563fa5df3e8)) + ## 0.30.0 (2026-01-22) Full Changelog: [v0.29.0...v0.30.0](https://github.com/G-Core/gcore-python/compare/v0.29.0...v0.30.0) diff --git a/api.md b/api.md index 4184baed..92044094 100644 --- a/api.md +++ b/api.md @@ -1919,7 +1919,7 @@ from gcore.types.streaming import ( StorageSeries, StreamSeries, UniqueViewers, - UniqueViewersCdn, + UniqueViewersCDN, Views, ViewsByBrowser, ViewsByCountry, @@ -1931,7 +1931,7 @@ from gcore.types.streaming import ( VodStatisticsSeries, VodTotalStreamDurationSeries, StatisticGetLiveUniqueViewersResponse, - StatisticGetVodWatchTimeTotalCdnResponse, + StatisticGetVodWatchTimeTotalCDNResponse, ) ``` @@ -1946,7 +1946,7 @@ Methods: - client.streaming.statistics.get_storage_series(\*\*params) -> StorageSeries - client.streaming.statistics.get_stream_series(\*\*params) -> StreamSeries - client.streaming.statistics.get_unique_viewers(\*\*params) -> UniqueViewers -- client.streaming.statistics.get_unique_viewers_cdn(\*\*params) -> UniqueViewersCdn +- client.streaming.statistics.get_unique_viewers_cdn(\*\*params) -> UniqueViewersCDN - client.streaming.statistics.get_views(\*\*params) -> Views - client.streaming.statistics.get_views_by_browsers(\*\*params) -> ViewsByBrowser - client.streaming.statistics.get_views_by_country(\*\*params) -> ViewsByCountry @@ -1959,7 +1959,7 @@ Methods: - client.streaming.statistics.get_vod_transcoding_duration(\*\*params) -> VodStatisticsSeries - client.streaming.statistics.get_vod_unique_viewers_cdn(\*\*params) -> VodStatisticsSeries - client.streaming.statistics.get_vod_watch_time_cdn(\*\*params) -> VodStatisticsSeries -- client.streaming.statistics.get_vod_watch_time_total_cdn(\*\*params) -> StatisticGetVodWatchTimeTotalCdnResponse +- client.streaming.statistics.get_vod_watch_time_total_cdn(\*\*params) -> StatisticGetVodWatchTimeTotalCDNResponse # Security @@ -2275,7 +2275,7 @@ Methods: - client.storage.buckets.policy.delete(bucket_name, \*, storage_id) -> None - client.storage.buckets.policy.get(bucket_name, \*, storage_id) -> PolicyGetResponse -# Cdn +# CDN Types: @@ -2283,73 +2283,73 @@ Types: from gcore.types.cdn import ( AlibabaRegions, AwsRegions, - CdnAccount, - CdnAccountLimits, - CdnAvailableFeatures, + CDNAccount, + CDNAccountLimits, + CDNAvailableFeatures, PurgeStatus, - CdnListPurgeStatusesResponse, + CDNListPurgeStatusesResponse, ) ``` Methods: -- client.cdn.get_account_limits() -> CdnAccountLimits -- client.cdn.get_account_overview() -> CdnAccount -- client.cdn.get_available_features() -> CdnAvailableFeatures +- client.cdn.get_account_limits() -> CDNAccountLimits +- client.cdn.get_account_overview() -> CDNAccount +- client.cdn.get_available_features() -> CDNAvailableFeatures - client.cdn.list_alibaba_regions() -> AlibabaRegions - client.cdn.list_aws_regions() -> AwsRegions -- client.cdn.list_purge_statuses(\*\*params) -> CdnListPurgeStatusesResponse -- client.cdn.update_account(\*\*params) -> CdnAccount +- client.cdn.list_purge_statuses(\*\*params) -> CDNListPurgeStatusesResponse +- client.cdn.update_account(\*\*params) -> CDNAccount -## Resources +## CDNResources Types: ```python -from gcore.types.cdn import CdnResource, CdnResourceList +from gcore.types.cdn import CDNResource, CDNResourceList ``` Methods: -- client.cdn.resources.create(\*\*params) -> CdnResource -- client.cdn.resources.update(resource_id, \*\*params) -> CdnResource -- client.cdn.resources.list(\*\*params) -> CdnResourceList -- client.cdn.resources.delete(resource_id) -> None -- client.cdn.resources.get(resource_id) -> CdnResource -- client.cdn.resources.prefetch(resource_id, \*\*params) -> None -- client.cdn.resources.prevalidate_ssl_le_certificate(resource_id) -> None -- client.cdn.resources.purge(resource_id, \*\*params) -> None -- client.cdn.resources.replace(resource_id, \*\*params) -> CdnResource +- client.cdn.cdn_resources.create(\*\*params) -> CDNResource +- client.cdn.cdn_resources.update(resource_id, \*\*params) -> CDNResource +- client.cdn.cdn_resources.list(\*\*params) -> CDNResourceList +- client.cdn.cdn_resources.delete(resource_id) -> None +- client.cdn.cdn_resources.get(resource_id) -> CDNResource +- client.cdn.cdn_resources.prefetch(resource_id, \*\*params) -> None +- client.cdn.cdn_resources.prevalidate_ssl_le_certificate(resource_id) -> None +- client.cdn.cdn_resources.purge(resource_id, \*\*params) -> None +- client.cdn.cdn_resources.replace(resource_id, \*\*params) -> CDNResource ### Shield Types: ```python -from gcore.types.cdn.resources import OriginShielding, OriginShieldingReplaced +from gcore.types.cdn.cdn_resources import OriginShielding, OriginShieldingReplaced ``` Methods: -- client.cdn.resources.shield.get(resource_id) -> OriginShielding -- client.cdn.resources.shield.replace(resource_id, \*\*params) -> object +- client.cdn.cdn_resources.shield.get(resource_id) -> OriginShielding +- client.cdn.cdn_resources.shield.replace(resource_id, \*\*params) -> object ### Rules Types: ```python -from gcore.types.cdn.resources import CdnResourceRule, RuleListResponse +from gcore.types.cdn.cdn_resources import CDNResourceRule, RuleListResponse ``` Methods: -- client.cdn.resources.rules.create(resource_id, \*\*params) -> CdnResourceRule -- client.cdn.resources.rules.update(rule_id, \*, resource_id, \*\*params) -> CdnResourceRule -- client.cdn.resources.rules.list(resource_id) -> RuleListResponse -- client.cdn.resources.rules.delete(rule_id, \*, resource_id) -> None -- client.cdn.resources.rules.get(rule_id, \*, resource_id) -> CdnResourceRule -- client.cdn.resources.rules.replace(rule_id, \*, resource_id, \*\*params) -> CdnResourceRule +- client.cdn.cdn_resources.rules.create(resource_id, \*\*params) -> CDNResourceRule +- client.cdn.cdn_resources.rules.update(rule_id, \*, resource_id, \*\*params) -> CDNResourceRule +- client.cdn.cdn_resources.rules.list(resource_id) -> RuleListResponse +- client.cdn.cdn_resources.rules.delete(rule_id, \*, resource_id) -> None +- client.cdn.cdn_resources.rules.get(rule_id, \*, resource_id) -> CDNResourceRule +- client.cdn.cdn_resources.rules.replace(rule_id, \*, resource_id, \*\*params) -> CDNResourceRule ## Shields @@ -2437,25 +2437,25 @@ Methods: Types: ```python -from gcore.types.cdn import CdnAuditLogEntry +from gcore.types.cdn import CDNAuditLogEntry ``` Methods: -- client.cdn.audit_logs.list(\*\*params) -> SyncOffsetPage[CdnAuditLogEntry] -- client.cdn.audit_logs.get(log_id) -> CdnAuditLogEntry +- client.cdn.audit_logs.list(\*\*params) -> SyncOffsetPage[CDNAuditLogEntry] +- client.cdn.audit_logs.get(log_id) -> CDNAuditLogEntry ## Logs Types: ```python -from gcore.types.cdn import CdnLogEntry +from gcore.types.cdn import CDNLogEntry ``` Methods: -- client.cdn.logs.list(\*\*params) -> SyncOffsetPageCdnLogs[Data] +- client.cdn.logs.list(\*\*params) -> SyncOffsetPageCDNLogs[Data] - client.cdn.logs.download(\*\*params) -> BinaryAPIResponse ## LogsUploader @@ -2564,12 +2564,12 @@ Methods: Types: ```python -from gcore.types.cdn import CdnMetrics, CdnMetricsGroups, CdnMetricsValues +from gcore.types.cdn import CDNMetrics, CDNMetricsGroups, CDNMetricsValues ``` Methods: -- client.cdn.metrics.list(\*\*params) -> CdnMetrics +- client.cdn.metrics.list(\*\*params) -> CDNMetrics ## IPRanges diff --git a/pyproject.toml b/pyproject.toml index 26af6423..3ad9b84a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "gcore" -version = "0.30.0" +version = "0.31.0" description = "The official Python library for the gcore API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/gcore/_base_client.py b/src/gcore/_base_client.py index e4303b57..e797b152 100644 --- a/src/gcore/_base_client.py +++ b/src/gcore/_base_client.py @@ -86,6 +86,7 @@ APIConnectionError, APIResponseValidationError, ) +from ._utils._json import openapi_dumps log: logging.Logger = logging.getLogger(__name__) @@ -554,8 +555,10 @@ def _build_request( kwargs["content"] = options.content elif isinstance(json_data, bytes): kwargs["content"] = json_data - else: - kwargs["json"] = json_data if is_given(json_data) else None + elif not files: + # Don't set content when JSON is sent as multipart/form-data, + # since httpx's content param overrides other body arguments + kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None kwargs["files"] = files else: headers.pop("Content-Type", None) diff --git a/src/gcore/_client.py b/src/gcore/_client.py index d900f571..e4ad2425 100644 --- a/src/gcore/_client.py +++ b/src/gcore/_client.py @@ -50,7 +50,7 @@ class Gcore(SyncAPIClient): security: security.SecurityResource dns: dns.DNSResource storage: storage.StorageResource - cdn: cdn.CdnResource + cdn: cdn.CDNResource with_raw_response: GcoreWithRawResponse with_streaming_response: GcoreWithStreamedResponse @@ -143,7 +143,7 @@ def __init__( self.security = security.SecurityResource(self) self.dns = dns.DNSResource(self) self.storage = storage.StorageResource(self) - self.cdn = cdn.CdnResource(self) + self.cdn = cdn.CDNResource(self) self.with_raw_response = GcoreWithRawResponse(self) self.with_streaming_response = GcoreWithStreamedResponse(self) @@ -287,7 +287,7 @@ class AsyncGcore(AsyncAPIClient): security: security.AsyncSecurityResource dns: dns.AsyncDNSResource storage: storage.AsyncStorageResource - cdn: cdn.AsyncCdnResource + cdn: cdn.AsyncCDNResource with_raw_response: AsyncGcoreWithRawResponse with_streaming_response: AsyncGcoreWithStreamedResponse @@ -380,7 +380,7 @@ def __init__( self.security = security.AsyncSecurityResource(self) self.dns = dns.AsyncDNSResource(self) self.storage = storage.AsyncStorageResource(self) - self.cdn = cdn.AsyncCdnResource(self) + self.cdn = cdn.AsyncCDNResource(self) self.with_raw_response = AsyncGcoreWithRawResponse(self) self.with_streaming_response = AsyncGcoreWithStreamedResponse(self) @@ -525,7 +525,7 @@ def __init__(self, client: Gcore) -> None: self.security = security.SecurityResourceWithRawResponse(client.security) self.dns = dns.DNSResourceWithRawResponse(client.dns) self.storage = storage.StorageResourceWithRawResponse(client.storage) - self.cdn = cdn.CdnResourceWithRawResponse(client.cdn) + self.cdn = cdn.CDNResourceWithRawResponse(client.cdn) class AsyncGcoreWithRawResponse: @@ -538,7 +538,7 @@ def __init__(self, client: AsyncGcore) -> None: self.security = security.AsyncSecurityResourceWithRawResponse(client.security) self.dns = dns.AsyncDNSResourceWithRawResponse(client.dns) self.storage = storage.AsyncStorageResourceWithRawResponse(client.storage) - self.cdn = cdn.AsyncCdnResourceWithRawResponse(client.cdn) + self.cdn = cdn.AsyncCDNResourceWithRawResponse(client.cdn) class GcoreWithStreamedResponse: @@ -551,7 +551,7 @@ def __init__(self, client: Gcore) -> None: self.security = security.SecurityResourceWithStreamingResponse(client.security) self.dns = dns.DNSResourceWithStreamingResponse(client.dns) self.storage = storage.StorageResourceWithStreamingResponse(client.storage) - self.cdn = cdn.CdnResourceWithStreamingResponse(client.cdn) + self.cdn = cdn.CDNResourceWithStreamingResponse(client.cdn) class AsyncGcoreWithStreamedResponse: @@ -564,7 +564,7 @@ def __init__(self, client: AsyncGcore) -> None: self.security = security.AsyncSecurityResourceWithStreamingResponse(client.security) self.dns = dns.AsyncDNSResourceWithStreamingResponse(client.dns) self.storage = storage.AsyncStorageResourceWithStreamingResponse(client.storage) - self.cdn = cdn.AsyncCdnResourceWithStreamingResponse(client.cdn) + self.cdn = cdn.AsyncCDNResourceWithStreamingResponse(client.cdn) Client = Gcore diff --git a/src/gcore/_compat.py b/src/gcore/_compat.py index bdef67f0..786ff42a 100644 --- a/src/gcore/_compat.py +++ b/src/gcore/_compat.py @@ -139,6 +139,7 @@ def model_dump( exclude_defaults: bool = False, warnings: bool = True, mode: Literal["json", "python"] = "python", + by_alias: bool | None = None, ) -> dict[str, Any]: if (not PYDANTIC_V1) or hasattr(model, "model_dump"): return model.model_dump( @@ -148,13 +149,12 @@ def model_dump( exclude_defaults=exclude_defaults, # warnings are not supported in Pydantic v1 warnings=True if PYDANTIC_V1 else warnings, + by_alias=by_alias, ) return cast( "dict[str, Any]", model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast] - exclude=exclude, - exclude_unset=exclude_unset, - exclude_defaults=exclude_defaults, + exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, by_alias=bool(by_alias) ), ) diff --git a/src/gcore/_utils/_json.py b/src/gcore/_utils/_json.py new file mode 100644 index 00000000..60584214 --- /dev/null +++ b/src/gcore/_utils/_json.py @@ -0,0 +1,35 @@ +import json +from typing import Any +from datetime import datetime +from typing_extensions import override + +import pydantic + +from .._compat import model_dump + + +def openapi_dumps(obj: Any) -> bytes: + """ + Serialize an object to UTF-8 encoded JSON bytes. + + Extends the standard json.dumps with support for additional types + commonly used in the SDK, such as `datetime`, `pydantic.BaseModel`, etc. + """ + return json.dumps( + obj, + cls=_CustomEncoder, + # Uses the same defaults as httpx's JSON serialization + ensure_ascii=False, + separators=(",", ":"), + allow_nan=False, + ).encode() + + +class _CustomEncoder(json.JSONEncoder): + @override + def default(self, o: Any) -> Any: + if isinstance(o, datetime): + return o.isoformat() + if isinstance(o, pydantic.BaseModel): + return model_dump(o, exclude_unset=True, mode="json", by_alias=True) + return super().default(o) diff --git a/src/gcore/_version.py b/src/gcore/_version.py index 574d5dd3..d06a94b9 100644 --- a/src/gcore/_version.py +++ b/src/gcore/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "gcore" -__version__ = "0.30.0" # x-release-please-version +__version__ = "0.31.0" # x-release-please-version diff --git a/src/gcore/pagination.py b/src/gcore/pagination.py index 24edbc64..872117cd 100644 --- a/src/gcore/pagination.py +++ b/src/gcore/pagination.py @@ -22,11 +22,11 @@ "AsyncPageStreamingAI", "SyncPageStreaming", "AsyncPageStreaming", - "SyncOffsetPageCdn", - "AsyncOffsetPageCdn", - "OffsetPageCdnLogsMeta", - "SyncOffsetPageCdnLogs", - "AsyncOffsetPageCdnLogs", + "SyncOffsetPageCDN", + "AsyncOffsetPageCDN", + "OffsetPageCDNLogsMeta", + "SyncOffsetPageCDNLogs", + "AsyncOffsetPageCDNLogs", ] _BaseModelT = TypeVar("_BaseModelT", bound=BaseModel) @@ -364,7 +364,7 @@ def build(cls: Type[_BaseModelT], *, response: Response, data: object) -> _BaseM ) -class SyncOffsetPageCdn(BaseSyncPage[_T], BasePage[_T], Generic[_T]): +class SyncOffsetPageCDN(BaseSyncPage[_T], BasePage[_T], Generic[_T]): items: List[_T] @override @@ -395,7 +395,7 @@ def build(cls: Type[_BaseModelT], *, response: Response, data: object) -> _BaseM ) -class AsyncOffsetPageCdn(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): +class AsyncOffsetPageCDN(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): items: List[_T] @override @@ -426,13 +426,13 @@ def build(cls: Type[_BaseModelT], *, response: Response, data: object) -> _BaseM ) -class OffsetPageCdnLogsMeta(BaseModel): +class OffsetPageCDNLogsMeta(BaseModel): count: Optional[int] = None -class SyncOffsetPageCdnLogs(BaseSyncPage[_T], BasePage[_T], Generic[_T]): +class SyncOffsetPageCDNLogs(BaseSyncPage[_T], BasePage[_T], Generic[_T]): data: List[_T] - meta: Optional[OffsetPageCdnLogsMeta] = None + meta: Optional[OffsetPageCDNLogsMeta] = None @override def _get_page_items(self) -> List[_T]: @@ -463,9 +463,9 @@ def next_page_info(self) -> Optional[PageInfo]: return None -class AsyncOffsetPageCdnLogs(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): +class AsyncOffsetPageCDNLogs(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): data: List[_T] - meta: Optional[OffsetPageCdnLogsMeta] = None + meta: Optional[OffsetPageCDNLogsMeta] = None @override def _get_page_items(self) -> List[_T]: diff --git a/src/gcore/resources/__init__.py b/src/gcore/resources/__init__.py index c8aaa6a7..d3d790e6 100644 --- a/src/gcore/resources/__init__.py +++ b/src/gcore/resources/__init__.py @@ -1,12 +1,12 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from .cdn import ( - CdnResource, - AsyncCdnResource, - CdnResourceWithRawResponse, - AsyncCdnResourceWithRawResponse, - CdnResourceWithStreamingResponse, - AsyncCdnResourceWithStreamingResponse, + CDNResource, + AsyncCDNResource, + CDNResourceWithRawResponse, + AsyncCDNResourceWithRawResponse, + CDNResourceWithStreamingResponse, + AsyncCDNResourceWithStreamingResponse, ) from .dns import ( DNSResource, @@ -122,10 +122,10 @@ "AsyncStorageResourceWithRawResponse", "StorageResourceWithStreamingResponse", "AsyncStorageResourceWithStreamingResponse", - "CdnResource", - "AsyncCdnResource", - "CdnResourceWithRawResponse", - "AsyncCdnResourceWithRawResponse", - "CdnResourceWithStreamingResponse", - "AsyncCdnResourceWithStreamingResponse", + "CDNResource", + "AsyncCDNResource", + "CDNResourceWithRawResponse", + "AsyncCDNResourceWithRawResponse", + "CDNResourceWithStreamingResponse", + "AsyncCDNResourceWithStreamingResponse", ] diff --git a/src/gcore/resources/cdn/__init__.py b/src/gcore/resources/cdn/__init__.py index 6fcdaceb..869fc050 100644 --- a/src/gcore/resources/cdn/__init__.py +++ b/src/gcore/resources/cdn/__init__.py @@ -1,12 +1,12 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from .cdn import ( - CdnResource, - AsyncCdnResource, - CdnResourceWithRawResponse, - AsyncCdnResourceWithRawResponse, - CdnResourceWithStreamingResponse, - AsyncCdnResourceWithStreamingResponse, + CDNResource, + AsyncCDNResource, + CDNResourceWithRawResponse, + AsyncCDNResourceWithRawResponse, + CDNResourceWithStreamingResponse, + AsyncCDNResourceWithStreamingResponse, ) from .logs import ( LogsResource, @@ -40,14 +40,6 @@ IPRangesResourceWithStreamingResponse, AsyncIPRangesResourceWithStreamingResponse, ) -from .resources import ( - ResourcesResource, - AsyncResourcesResource, - ResourcesResourceWithRawResponse, - AsyncResourcesResourceWithRawResponse, - ResourcesResourceWithStreamingResponse, - AsyncResourcesResourceWithStreamingResponse, -) from .audit_logs import ( AuditLogsResource, AsyncAuditLogsResource, @@ -72,6 +64,14 @@ CertificatesResourceWithStreamingResponse, AsyncCertificatesResourceWithStreamingResponse, ) +from .cdn_resources import ( + CDNResourcesResource, + AsyncCDNResourcesResource, + CDNResourcesResourceWithRawResponse, + AsyncCDNResourcesResourceWithRawResponse, + CDNResourcesResourceWithStreamingResponse, + AsyncCDNResourcesResourceWithStreamingResponse, +) from .logs_uploader import ( LogsUploaderResource, AsyncLogsUploaderResource, @@ -114,12 +114,12 @@ ) __all__ = [ - "ResourcesResource", - "AsyncResourcesResource", - "ResourcesResourceWithRawResponse", - "AsyncResourcesResourceWithRawResponse", - "ResourcesResourceWithStreamingResponse", - "AsyncResourcesResourceWithStreamingResponse", + "CDNResourcesResource", + "AsyncCDNResourcesResource", + "CDNResourcesResourceWithRawResponse", + "AsyncCDNResourcesResourceWithRawResponse", + "CDNResourcesResourceWithStreamingResponse", + "AsyncCDNResourcesResourceWithStreamingResponse", "ShieldsResource", "AsyncShieldsResource", "ShieldsResourceWithRawResponse", @@ -192,10 +192,10 @@ "AsyncIPRangesResourceWithRawResponse", "IPRangesResourceWithStreamingResponse", "AsyncIPRangesResourceWithStreamingResponse", - "CdnResource", - "AsyncCdnResource", - "CdnResourceWithRawResponse", - "AsyncCdnResourceWithRawResponse", - "CdnResourceWithStreamingResponse", - "AsyncCdnResourceWithStreamingResponse", + "CDNResource", + "AsyncCDNResource", + "CDNResourceWithRawResponse", + "AsyncCDNResourceWithRawResponse", + "CDNResourceWithStreamingResponse", + "AsyncCDNResourceWithStreamingResponse", ] diff --git a/src/gcore/resources/cdn/audit_logs.py b/src/gcore/resources/cdn/audit_logs.py index 910d3524..e77a7315 100644 --- a/src/gcore/resources/cdn/audit_logs.py +++ b/src/gcore/resources/cdn/audit_logs.py @@ -17,7 +17,7 @@ from ...types.cdn import audit_log_list_params from ...pagination import SyncOffsetPage, AsyncOffsetPage from ..._base_client import AsyncPaginator, make_request_options -from ...types.cdn.cdn_audit_log_entry import CdnAuditLogEntry +from ...types.cdn.cdn_audit_log_entry import CDNAuditLogEntry __all__ = ["AuditLogsResource", "AsyncAuditLogsResource"] @@ -62,7 +62,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncOffsetPage[CdnAuditLogEntry]: + ) -> SyncOffsetPage[CDNAuditLogEntry]: """ Get information about all CDN activity logs records. @@ -126,7 +126,7 @@ def list( """ return self._get_api_list( "/cdn/activity_log/requests", - page=SyncOffsetPage[CdnAuditLogEntry], + page=SyncOffsetPage[CDNAuditLogEntry], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -149,7 +149,7 @@ def list( audit_log_list_params.AuditLogListParams, ), ), - model=CdnAuditLogEntry, + model=CDNAuditLogEntry, ) def get( @@ -162,7 +162,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAuditLogEntry: + ) -> CDNAuditLogEntry: """ Get information about CDN activity logs record. @@ -182,7 +182,7 @@ def get( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAuditLogEntry, + cast_to=CDNAuditLogEntry, ) @@ -226,7 +226,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[CdnAuditLogEntry, AsyncOffsetPage[CdnAuditLogEntry]]: + ) -> AsyncPaginator[CDNAuditLogEntry, AsyncOffsetPage[CDNAuditLogEntry]]: """ Get information about all CDN activity logs records. @@ -290,7 +290,7 @@ def list( """ return self._get_api_list( "/cdn/activity_log/requests", - page=AsyncOffsetPage[CdnAuditLogEntry], + page=AsyncOffsetPage[CDNAuditLogEntry], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -313,7 +313,7 @@ def list( audit_log_list_params.AuditLogListParams, ), ), - model=CdnAuditLogEntry, + model=CDNAuditLogEntry, ) async def get( @@ -326,7 +326,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAuditLogEntry: + ) -> CDNAuditLogEntry: """ Get information about CDN activity logs record. @@ -346,7 +346,7 @@ async def get( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAuditLogEntry, + cast_to=CDNAuditLogEntry, ) diff --git a/src/gcore/resources/cdn/cdn.py b/src/gcore/resources/cdn/cdn.py index 0fb78a73..771c3776 100644 --- a/src/gcore/resources/cdn/cdn.py +++ b/src/gcore/resources/cdn/cdn.py @@ -96,16 +96,8 @@ NetworkCapacityResourceWithStreamingResponse, AsyncNetworkCapacityResourceWithStreamingResponse, ) -from .resources.resources import ( - ResourcesResource, - AsyncResourcesResource, - ResourcesResourceWithRawResponse, - AsyncResourcesResourceWithRawResponse, - ResourcesResourceWithStreamingResponse, - AsyncResourcesResourceWithStreamingResponse, -) from ...types.cdn.aws_regions import AwsRegions -from ...types.cdn.cdn_account import CdnAccount +from ...types.cdn.cdn_account import CDNAccount from .trusted_ca_certificates import ( TrustedCaCertificatesResource, AsyncTrustedCaCertificatesResource, @@ -115,6 +107,14 @@ AsyncTrustedCaCertificatesResourceWithStreamingResponse, ) from ...types.cdn.alibaba_regions import AlibabaRegions +from .cdn_resources.cdn_resources import ( + CDNResourcesResource, + AsyncCDNResourcesResource, + CDNResourcesResourceWithRawResponse, + AsyncCDNResourcesResourceWithRawResponse, + CDNResourcesResourceWithStreamingResponse, + AsyncCDNResourcesResourceWithStreamingResponse, +) from .logs_uploader.logs_uploader import ( LogsUploaderResource, AsyncLogsUploaderResource, @@ -123,17 +123,17 @@ LogsUploaderResourceWithStreamingResponse, AsyncLogsUploaderResourceWithStreamingResponse, ) -from ...types.cdn.cdn_account_limits import CdnAccountLimits -from ...types.cdn.cdn_available_features import CdnAvailableFeatures -from ...types.cdn.cdn_list_purge_statuses_response import CdnListPurgeStatusesResponse +from ...types.cdn.cdn_account_limits import CDNAccountLimits +from ...types.cdn.cdn_available_features import CDNAvailableFeatures +from ...types.cdn.cdn_list_purge_statuses_response import CDNListPurgeStatusesResponse -__all__ = ["CdnResource", "AsyncCdnResource"] +__all__ = ["CDNResource", "AsyncCDNResource"] -class CdnResource(SyncAPIResource): +class CDNResource(SyncAPIResource): @cached_property - def resources(self) -> ResourcesResource: - return ResourcesResource(self._client) + def cdn_resources(self) -> CDNResourcesResource: + return CDNResourcesResource(self._client) @cached_property def shields(self) -> ShieldsResource: @@ -184,23 +184,23 @@ def ip_ranges(self) -> IPRangesResource: return IPRangesResource(self._client) @cached_property - def with_raw_response(self) -> CdnResourceWithRawResponse: + def with_raw_response(self) -> CDNResourceWithRawResponse: """ 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/G-Core/gcore-python#accessing-raw-response-data-eg-headers """ - return CdnResourceWithRawResponse(self) + return CDNResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> CdnResourceWithStreamingResponse: + def with_streaming_response(self) -> CDNResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response """ - return CdnResourceWithStreamingResponse(self) + return CDNResourceWithStreamingResponse(self) def get_account_limits( self, @@ -211,14 +211,14 @@ def get_account_limits( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAccountLimits: + ) -> CDNAccountLimits: """Get information about CDN service limits.""" return self._get( "/cdn/clients/me/limits", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAccountLimits, + cast_to=CDNAccountLimits, ) def get_account_overview( @@ -230,14 +230,14 @@ def get_account_overview( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAccount: + ) -> CDNAccount: """Get information about CDN service.""" return self._get( "/cdn/clients/me", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAccount, + cast_to=CDNAccount, ) def get_available_features( @@ -249,14 +249,14 @@ def get_available_features( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAvailableFeatures: + ) -> CDNAvailableFeatures: """Get information about available CDN features.""" return self._get( "/cdn/clients/me/features", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAvailableFeatures, + cast_to=CDNAvailableFeatures, ) def list_alibaba_regions( @@ -313,7 +313,7 @@ def list_purge_statuses( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnListPurgeStatusesResponse: + ) -> CDNListPurgeStatusesResponse: """ Get purges history. @@ -386,10 +386,10 @@ def list_purge_statuses( "status": status, "to_created": to_created, }, - cdn_list_purge_statuses_params.CdnListPurgeStatusesParams, + cdn_list_purge_statuses_params.CDNListPurgeStatusesParams, ), ), - cast_to=CdnListPurgeStatusesResponse, + cast_to=CDNListPurgeStatusesResponse, ) def update_account( @@ -402,7 +402,7 @@ def update_account( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAccount: + ) -> CDNAccount: """ Change information about CDN service. @@ -422,19 +422,19 @@ def update_account( return self._patch( "/cdn/clients/me", body=maybe_transform( - {"utilization_level": utilization_level}, cdn_update_account_params.CdnUpdateAccountParams + {"utilization_level": utilization_level}, cdn_update_account_params.CDNUpdateAccountParams ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAccount, + cast_to=CDNAccount, ) -class AsyncCdnResource(AsyncAPIResource): +class AsyncCDNResource(AsyncAPIResource): @cached_property - def resources(self) -> AsyncResourcesResource: - return AsyncResourcesResource(self._client) + def cdn_resources(self) -> AsyncCDNResourcesResource: + return AsyncCDNResourcesResource(self._client) @cached_property def shields(self) -> AsyncShieldsResource: @@ -485,23 +485,23 @@ def ip_ranges(self) -> AsyncIPRangesResource: return AsyncIPRangesResource(self._client) @cached_property - def with_raw_response(self) -> AsyncCdnResourceWithRawResponse: + def with_raw_response(self) -> AsyncCDNResourceWithRawResponse: """ 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/G-Core/gcore-python#accessing-raw-response-data-eg-headers """ - return AsyncCdnResourceWithRawResponse(self) + return AsyncCDNResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncCdnResourceWithStreamingResponse: + def with_streaming_response(self) -> AsyncCDNResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response """ - return AsyncCdnResourceWithStreamingResponse(self) + return AsyncCDNResourceWithStreamingResponse(self) async def get_account_limits( self, @@ -512,14 +512,14 @@ async def get_account_limits( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAccountLimits: + ) -> CDNAccountLimits: """Get information about CDN service limits.""" return await self._get( "/cdn/clients/me/limits", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAccountLimits, + cast_to=CDNAccountLimits, ) async def get_account_overview( @@ -531,14 +531,14 @@ async def get_account_overview( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAccount: + ) -> CDNAccount: """Get information about CDN service.""" return await self._get( "/cdn/clients/me", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAccount, + cast_to=CDNAccount, ) async def get_available_features( @@ -550,14 +550,14 @@ async def get_available_features( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAvailableFeatures: + ) -> CDNAvailableFeatures: """Get information about available CDN features.""" return await self._get( "/cdn/clients/me/features", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAvailableFeatures, + cast_to=CDNAvailableFeatures, ) async def list_alibaba_regions( @@ -614,7 +614,7 @@ async def list_purge_statuses( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnListPurgeStatusesResponse: + ) -> CDNListPurgeStatusesResponse: """ Get purges history. @@ -687,10 +687,10 @@ async def list_purge_statuses( "status": status, "to_created": to_created, }, - cdn_list_purge_statuses_params.CdnListPurgeStatusesParams, + cdn_list_purge_statuses_params.CDNListPurgeStatusesParams, ), ), - cast_to=CdnListPurgeStatusesResponse, + cast_to=CDNListPurgeStatusesResponse, ) async def update_account( @@ -703,7 +703,7 @@ async def update_account( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnAccount: + ) -> CDNAccount: """ Change information about CDN service. @@ -723,17 +723,17 @@ async def update_account( return await self._patch( "/cdn/clients/me", body=await async_maybe_transform( - {"utilization_level": utilization_level}, cdn_update_account_params.CdnUpdateAccountParams + {"utilization_level": utilization_level}, cdn_update_account_params.CDNUpdateAccountParams ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnAccount, + cast_to=CDNAccount, ) -class CdnResourceWithRawResponse: - def __init__(self, cdn: CdnResource) -> None: +class CDNResourceWithRawResponse: + def __init__(self, cdn: CDNResource) -> None: self._cdn = cdn self.get_account_limits = to_raw_response_wrapper( @@ -759,8 +759,8 @@ def __init__(self, cdn: CdnResource) -> None: ) @cached_property - def resources(self) -> ResourcesResourceWithRawResponse: - return ResourcesResourceWithRawResponse(self._cdn.resources) + def cdn_resources(self) -> CDNResourcesResourceWithRawResponse: + return CDNResourcesResourceWithRawResponse(self._cdn.cdn_resources) @cached_property def shields(self) -> ShieldsResourceWithRawResponse: @@ -811,8 +811,8 @@ def ip_ranges(self) -> IPRangesResourceWithRawResponse: return IPRangesResourceWithRawResponse(self._cdn.ip_ranges) -class AsyncCdnResourceWithRawResponse: - def __init__(self, cdn: AsyncCdnResource) -> None: +class AsyncCDNResourceWithRawResponse: + def __init__(self, cdn: AsyncCDNResource) -> None: self._cdn = cdn self.get_account_limits = async_to_raw_response_wrapper( @@ -838,8 +838,8 @@ def __init__(self, cdn: AsyncCdnResource) -> None: ) @cached_property - def resources(self) -> AsyncResourcesResourceWithRawResponse: - return AsyncResourcesResourceWithRawResponse(self._cdn.resources) + def cdn_resources(self) -> AsyncCDNResourcesResourceWithRawResponse: + return AsyncCDNResourcesResourceWithRawResponse(self._cdn.cdn_resources) @cached_property def shields(self) -> AsyncShieldsResourceWithRawResponse: @@ -890,8 +890,8 @@ def ip_ranges(self) -> AsyncIPRangesResourceWithRawResponse: return AsyncIPRangesResourceWithRawResponse(self._cdn.ip_ranges) -class CdnResourceWithStreamingResponse: - def __init__(self, cdn: CdnResource) -> None: +class CDNResourceWithStreamingResponse: + def __init__(self, cdn: CDNResource) -> None: self._cdn = cdn self.get_account_limits = to_streamed_response_wrapper( @@ -917,8 +917,8 @@ def __init__(self, cdn: CdnResource) -> None: ) @cached_property - def resources(self) -> ResourcesResourceWithStreamingResponse: - return ResourcesResourceWithStreamingResponse(self._cdn.resources) + def cdn_resources(self) -> CDNResourcesResourceWithStreamingResponse: + return CDNResourcesResourceWithStreamingResponse(self._cdn.cdn_resources) @cached_property def shields(self) -> ShieldsResourceWithStreamingResponse: @@ -969,8 +969,8 @@ def ip_ranges(self) -> IPRangesResourceWithStreamingResponse: return IPRangesResourceWithStreamingResponse(self._cdn.ip_ranges) -class AsyncCdnResourceWithStreamingResponse: - def __init__(self, cdn: AsyncCdnResource) -> None: +class AsyncCDNResourceWithStreamingResponse: + def __init__(self, cdn: AsyncCDNResource) -> None: self._cdn = cdn self.get_account_limits = async_to_streamed_response_wrapper( @@ -996,8 +996,8 @@ def __init__(self, cdn: AsyncCdnResource) -> None: ) @cached_property - def resources(self) -> AsyncResourcesResourceWithStreamingResponse: - return AsyncResourcesResourceWithStreamingResponse(self._cdn.resources) + def cdn_resources(self) -> AsyncCDNResourcesResourceWithStreamingResponse: + return AsyncCDNResourcesResourceWithStreamingResponse(self._cdn.cdn_resources) @cached_property def shields(self) -> AsyncShieldsResourceWithStreamingResponse: diff --git a/src/gcore/resources/cdn/resources/__init__.py b/src/gcore/resources/cdn/cdn_resources/__init__.py similarity index 65% rename from src/gcore/resources/cdn/resources/__init__.py rename to src/gcore/resources/cdn/cdn_resources/__init__.py index e72105aa..b8fee4c6 100644 --- a/src/gcore/resources/cdn/resources/__init__.py +++ b/src/gcore/resources/cdn/cdn_resources/__init__.py @@ -16,13 +16,13 @@ ShieldResourceWithStreamingResponse, AsyncShieldResourceWithStreamingResponse, ) -from .resources import ( - ResourcesResource, - AsyncResourcesResource, - ResourcesResourceWithRawResponse, - AsyncResourcesResourceWithRawResponse, - ResourcesResourceWithStreamingResponse, - AsyncResourcesResourceWithStreamingResponse, +from .cdn_resources import ( + CDNResourcesResource, + AsyncCDNResourcesResource, + CDNResourcesResourceWithRawResponse, + AsyncCDNResourcesResourceWithRawResponse, + CDNResourcesResourceWithStreamingResponse, + AsyncCDNResourcesResourceWithStreamingResponse, ) __all__ = [ @@ -38,10 +38,10 @@ "AsyncRulesResourceWithRawResponse", "RulesResourceWithStreamingResponse", "AsyncRulesResourceWithStreamingResponse", - "ResourcesResource", - "AsyncResourcesResource", - "ResourcesResourceWithRawResponse", - "AsyncResourcesResourceWithRawResponse", - "ResourcesResourceWithStreamingResponse", - "AsyncResourcesResourceWithStreamingResponse", + "CDNResourcesResource", + "AsyncCDNResourcesResource", + "CDNResourcesResourceWithRawResponse", + "AsyncCDNResourcesResourceWithRawResponse", + "CDNResourcesResourceWithStreamingResponse", + "AsyncCDNResourcesResourceWithStreamingResponse", ] diff --git a/src/gcore/resources/cdn/resources/resources.py b/src/gcore/resources/cdn/cdn_resources/cdn_resources.py similarity index 93% rename from src/gcore/resources/cdn/resources/resources.py rename to src/gcore/resources/cdn/cdn_resources/cdn_resources.py index 2ceda584..e92683c6 100644 --- a/src/gcore/resources/cdn/resources/resources.py +++ b/src/gcore/resources/cdn/cdn_resources/cdn_resources.py @@ -34,21 +34,21 @@ async_to_streamed_response_wrapper, ) from ....types.cdn import ( - resource_list_params, - resource_purge_params, - resource_create_params, - resource_update_params, - resource_replace_params, - resource_prefetch_params, + cdn_resource_list_params, + cdn_resource_purge_params, + cdn_resource_create_params, + cdn_resource_update_params, + cdn_resource_replace_params, + cdn_resource_prefetch_params, ) from ...._base_client import make_request_options -from ....types.cdn.cdn_resource import CdnResource -from ....types.cdn.cdn_resource_list import CdnResourceList +from ....types.cdn.cdn_resource import CDNResource +from ....types.cdn.cdn_resource_list import CDNResourceList -__all__ = ["ResourcesResource", "AsyncResourcesResource"] +__all__ = ["CDNResourcesResource", "AsyncCDNResourcesResource"] -class ResourcesResource(SyncAPIResource): +class CDNResourcesResource(SyncAPIResource): @cached_property def shield(self) -> ShieldResource: return ShieldResource(self._client) @@ -58,23 +58,23 @@ def rules(self) -> RulesResource: return RulesResource(self._client) @cached_property - def with_raw_response(self) -> ResourcesResourceWithRawResponse: + def with_raw_response(self) -> CDNResourcesResourceWithRawResponse: """ 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/G-Core/gcore-python#accessing-raw-response-data-eg-headers """ - return ResourcesResourceWithRawResponse(self) + return CDNResourcesResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> ResourcesResourceWithStreamingResponse: + def with_streaming_response(self) -> CDNResourcesResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response """ - return ResourcesResourceWithStreamingResponse(self) + return CDNResourcesResourceWithStreamingResponse(self) def create( self, @@ -85,7 +85,7 @@ def create( active: bool | Omit = omit, description: str | Omit = omit, name: Optional[str] | Omit = omit, - options: resource_create_params.Options | Omit = omit, + options: cdn_resource_create_params.Options | Omit = omit, origin_protocol: Literal["HTTP", "HTTPS", "MATCH"] | Omit = omit, primary_resource: Optional[int] | Omit = omit, proxy_ssl_ca: Optional[int] | Omit = omit, @@ -101,7 +101,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResource: + ) -> CDNResource: """ Create CDN resource @@ -220,12 +220,12 @@ def create( "ssl_enabled": ssl_enabled, "waap_api_domain_enabled": waap_api_domain_enabled, }, - resource_create_params.ResourceCreateParams, + cdn_resource_create_params.CDNResourceCreateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResource, + cast_to=CDNResource, ) def update( @@ -235,7 +235,7 @@ def update( active: bool | Omit = omit, description: str | Omit = omit, name: Optional[str] | Omit = omit, - options: resource_update_params.Options | Omit = omit, + options: cdn_resource_update_params.Options | Omit = omit, origin_group: int | Omit = omit, origin_protocol: Literal["HTTP", "HTTPS", "MATCH"] | Omit = omit, proxy_ssl_ca: Optional[int] | Omit = omit, @@ -250,7 +250,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResource: + ) -> CDNResource: """ Change CDN resource @@ -343,12 +343,12 @@ def update( "ssl_data": ssl_data, "ssl_enabled": ssl_enabled, }, - resource_update_params.ResourceUpdateParams, + cdn_resource_update_params.CDNResourceUpdateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResource, + cast_to=CDNResource, ) def list( @@ -376,7 +376,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceList: + ) -> CDNResourceList: """ Get information about all CDN resources in your account. @@ -484,10 +484,10 @@ def list( "suspend": suspend, "vp_enabled": vp_enabled, }, - resource_list_params.ResourceListParams, + cdn_resource_list_params.CDNResourceListParams, ), ), - cast_to=CdnResourceList, + cast_to=CDNResourceList, ) def delete( @@ -542,7 +542,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResource: + ) -> CDNResource: """ Get CDN resource details @@ -560,7 +560,7 @@ def get( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResource, + cast_to=CDNResource, ) def prefetch( @@ -604,7 +604,7 @@ def prefetch( extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._post( f"/cdn/resources/{resource_id}/prefetch", - body=maybe_transform({"paths": paths}, resource_prefetch_params.ResourcePrefetchParams), + body=maybe_transform({"paths": paths}, cdn_resource_prefetch_params.CDNResourcePrefetchParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -817,7 +817,7 @@ def purge( "urls": urls, "paths": paths, }, - resource_purge_params.ResourcePurgeParams, + cdn_resource_purge_params.CDNResourcePurgeParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -833,7 +833,7 @@ def replace( active: bool | Omit = omit, description: str | Omit = omit, name: Optional[str] | Omit = omit, - options: resource_replace_params.Options | Omit = omit, + options: cdn_resource_replace_params.Options | Omit = omit, origin_protocol: Literal["HTTP", "HTTPS", "MATCH"] | Omit = omit, proxy_ssl_ca: Optional[int] | Omit = omit, proxy_ssl_data: Optional[int] | Omit = omit, @@ -848,7 +848,7 @@ def replace( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResource: + ) -> CDNResource: """ Change CDN resource @@ -949,16 +949,16 @@ def replace( "ssl_enabled": ssl_enabled, "waap_api_domain_enabled": waap_api_domain_enabled, }, - resource_replace_params.ResourceReplaceParams, + cdn_resource_replace_params.CDNResourceReplaceParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResource, + cast_to=CDNResource, ) -class AsyncResourcesResource(AsyncAPIResource): +class AsyncCDNResourcesResource(AsyncAPIResource): @cached_property def shield(self) -> AsyncShieldResource: return AsyncShieldResource(self._client) @@ -968,23 +968,23 @@ def rules(self) -> AsyncRulesResource: return AsyncRulesResource(self._client) @cached_property - def with_raw_response(self) -> AsyncResourcesResourceWithRawResponse: + def with_raw_response(self) -> AsyncCDNResourcesResourceWithRawResponse: """ 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/G-Core/gcore-python#accessing-raw-response-data-eg-headers """ - return AsyncResourcesResourceWithRawResponse(self) + return AsyncCDNResourcesResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncResourcesResourceWithStreamingResponse: + def with_streaming_response(self) -> AsyncCDNResourcesResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/G-Core/gcore-python#with_streaming_response """ - return AsyncResourcesResourceWithStreamingResponse(self) + return AsyncCDNResourcesResourceWithStreamingResponse(self) async def create( self, @@ -995,7 +995,7 @@ async def create( active: bool | Omit = omit, description: str | Omit = omit, name: Optional[str] | Omit = omit, - options: resource_create_params.Options | Omit = omit, + options: cdn_resource_create_params.Options | Omit = omit, origin_protocol: Literal["HTTP", "HTTPS", "MATCH"] | Omit = omit, primary_resource: Optional[int] | Omit = omit, proxy_ssl_ca: Optional[int] | Omit = omit, @@ -1011,7 +1011,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResource: + ) -> CDNResource: """ Create CDN resource @@ -1130,12 +1130,12 @@ async def create( "ssl_enabled": ssl_enabled, "waap_api_domain_enabled": waap_api_domain_enabled, }, - resource_create_params.ResourceCreateParams, + cdn_resource_create_params.CDNResourceCreateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResource, + cast_to=CDNResource, ) async def update( @@ -1145,7 +1145,7 @@ async def update( active: bool | Omit = omit, description: str | Omit = omit, name: Optional[str] | Omit = omit, - options: resource_update_params.Options | Omit = omit, + options: cdn_resource_update_params.Options | Omit = omit, origin_group: int | Omit = omit, origin_protocol: Literal["HTTP", "HTTPS", "MATCH"] | Omit = omit, proxy_ssl_ca: Optional[int] | Omit = omit, @@ -1160,7 +1160,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResource: + ) -> CDNResource: """ Change CDN resource @@ -1253,12 +1253,12 @@ async def update( "ssl_data": ssl_data, "ssl_enabled": ssl_enabled, }, - resource_update_params.ResourceUpdateParams, + cdn_resource_update_params.CDNResourceUpdateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResource, + cast_to=CDNResource, ) async def list( @@ -1286,7 +1286,7 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceList: + ) -> CDNResourceList: """ Get information about all CDN resources in your account. @@ -1394,10 +1394,10 @@ async def list( "suspend": suspend, "vp_enabled": vp_enabled, }, - resource_list_params.ResourceListParams, + cdn_resource_list_params.CDNResourceListParams, ), ), - cast_to=CdnResourceList, + cast_to=CDNResourceList, ) async def delete( @@ -1452,7 +1452,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResource: + ) -> CDNResource: """ Get CDN resource details @@ -1470,7 +1470,7 @@ async def get( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResource, + cast_to=CDNResource, ) async def prefetch( @@ -1514,7 +1514,7 @@ async def prefetch( extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._post( f"/cdn/resources/{resource_id}/prefetch", - body=await async_maybe_transform({"paths": paths}, resource_prefetch_params.ResourcePrefetchParams), + body=await async_maybe_transform({"paths": paths}, cdn_resource_prefetch_params.CDNResourcePrefetchParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1727,7 +1727,7 @@ async def purge( "urls": urls, "paths": paths, }, - resource_purge_params.ResourcePurgeParams, + cdn_resource_purge_params.CDNResourcePurgeParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -1743,7 +1743,7 @@ async def replace( active: bool | Omit = omit, description: str | Omit = omit, name: Optional[str] | Omit = omit, - options: resource_replace_params.Options | Omit = omit, + options: cdn_resource_replace_params.Options | Omit = omit, origin_protocol: Literal["HTTP", "HTTPS", "MATCH"] | Omit = omit, proxy_ssl_ca: Optional[int] | Omit = omit, proxy_ssl_data: Optional[int] | Omit = omit, @@ -1758,7 +1758,7 @@ async def replace( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResource: + ) -> CDNResource: """ Change CDN resource @@ -1859,174 +1859,174 @@ async def replace( "ssl_enabled": ssl_enabled, "waap_api_domain_enabled": waap_api_domain_enabled, }, - resource_replace_params.ResourceReplaceParams, + cdn_resource_replace_params.CDNResourceReplaceParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResource, + cast_to=CDNResource, ) -class ResourcesResourceWithRawResponse: - def __init__(self, resources: ResourcesResource) -> None: - self._resources = resources +class CDNResourcesResourceWithRawResponse: + def __init__(self, cdn_resources: CDNResourcesResource) -> None: + self._cdn_resources = cdn_resources self.create = to_raw_response_wrapper( - resources.create, + cdn_resources.create, ) self.update = to_raw_response_wrapper( - resources.update, + cdn_resources.update, ) self.list = to_raw_response_wrapper( - resources.list, + cdn_resources.list, ) self.delete = to_raw_response_wrapper( - resources.delete, + cdn_resources.delete, ) self.get = to_raw_response_wrapper( - resources.get, + cdn_resources.get, ) self.prefetch = to_raw_response_wrapper( - resources.prefetch, + cdn_resources.prefetch, ) self.prevalidate_ssl_le_certificate = to_raw_response_wrapper( - resources.prevalidate_ssl_le_certificate, + cdn_resources.prevalidate_ssl_le_certificate, ) self.purge = to_raw_response_wrapper( - resources.purge, + cdn_resources.purge, ) self.replace = to_raw_response_wrapper( - resources.replace, + cdn_resources.replace, ) @cached_property def shield(self) -> ShieldResourceWithRawResponse: - return ShieldResourceWithRawResponse(self._resources.shield) + return ShieldResourceWithRawResponse(self._cdn_resources.shield) @cached_property def rules(self) -> RulesResourceWithRawResponse: - return RulesResourceWithRawResponse(self._resources.rules) + return RulesResourceWithRawResponse(self._cdn_resources.rules) -class AsyncResourcesResourceWithRawResponse: - def __init__(self, resources: AsyncResourcesResource) -> None: - self._resources = resources +class AsyncCDNResourcesResourceWithRawResponse: + def __init__(self, cdn_resources: AsyncCDNResourcesResource) -> None: + self._cdn_resources = cdn_resources self.create = async_to_raw_response_wrapper( - resources.create, + cdn_resources.create, ) self.update = async_to_raw_response_wrapper( - resources.update, + cdn_resources.update, ) self.list = async_to_raw_response_wrapper( - resources.list, + cdn_resources.list, ) self.delete = async_to_raw_response_wrapper( - resources.delete, + cdn_resources.delete, ) self.get = async_to_raw_response_wrapper( - resources.get, + cdn_resources.get, ) self.prefetch = async_to_raw_response_wrapper( - resources.prefetch, + cdn_resources.prefetch, ) self.prevalidate_ssl_le_certificate = async_to_raw_response_wrapper( - resources.prevalidate_ssl_le_certificate, + cdn_resources.prevalidate_ssl_le_certificate, ) self.purge = async_to_raw_response_wrapper( - resources.purge, + cdn_resources.purge, ) self.replace = async_to_raw_response_wrapper( - resources.replace, + cdn_resources.replace, ) @cached_property def shield(self) -> AsyncShieldResourceWithRawResponse: - return AsyncShieldResourceWithRawResponse(self._resources.shield) + return AsyncShieldResourceWithRawResponse(self._cdn_resources.shield) @cached_property def rules(self) -> AsyncRulesResourceWithRawResponse: - return AsyncRulesResourceWithRawResponse(self._resources.rules) + return AsyncRulesResourceWithRawResponse(self._cdn_resources.rules) -class ResourcesResourceWithStreamingResponse: - def __init__(self, resources: ResourcesResource) -> None: - self._resources = resources +class CDNResourcesResourceWithStreamingResponse: + def __init__(self, cdn_resources: CDNResourcesResource) -> None: + self._cdn_resources = cdn_resources self.create = to_streamed_response_wrapper( - resources.create, + cdn_resources.create, ) self.update = to_streamed_response_wrapper( - resources.update, + cdn_resources.update, ) self.list = to_streamed_response_wrapper( - resources.list, + cdn_resources.list, ) self.delete = to_streamed_response_wrapper( - resources.delete, + cdn_resources.delete, ) self.get = to_streamed_response_wrapper( - resources.get, + cdn_resources.get, ) self.prefetch = to_streamed_response_wrapper( - resources.prefetch, + cdn_resources.prefetch, ) self.prevalidate_ssl_le_certificate = to_streamed_response_wrapper( - resources.prevalidate_ssl_le_certificate, + cdn_resources.prevalidate_ssl_le_certificate, ) self.purge = to_streamed_response_wrapper( - resources.purge, + cdn_resources.purge, ) self.replace = to_streamed_response_wrapper( - resources.replace, + cdn_resources.replace, ) @cached_property def shield(self) -> ShieldResourceWithStreamingResponse: - return ShieldResourceWithStreamingResponse(self._resources.shield) + return ShieldResourceWithStreamingResponse(self._cdn_resources.shield) @cached_property def rules(self) -> RulesResourceWithStreamingResponse: - return RulesResourceWithStreamingResponse(self._resources.rules) + return RulesResourceWithStreamingResponse(self._cdn_resources.rules) -class AsyncResourcesResourceWithStreamingResponse: - def __init__(self, resources: AsyncResourcesResource) -> None: - self._resources = resources +class AsyncCDNResourcesResourceWithStreamingResponse: + def __init__(self, cdn_resources: AsyncCDNResourcesResource) -> None: + self._cdn_resources = cdn_resources self.create = async_to_streamed_response_wrapper( - resources.create, + cdn_resources.create, ) self.update = async_to_streamed_response_wrapper( - resources.update, + cdn_resources.update, ) self.list = async_to_streamed_response_wrapper( - resources.list, + cdn_resources.list, ) self.delete = async_to_streamed_response_wrapper( - resources.delete, + cdn_resources.delete, ) self.get = async_to_streamed_response_wrapper( - resources.get, + cdn_resources.get, ) self.prefetch = async_to_streamed_response_wrapper( - resources.prefetch, + cdn_resources.prefetch, ) self.prevalidate_ssl_le_certificate = async_to_streamed_response_wrapper( - resources.prevalidate_ssl_le_certificate, + cdn_resources.prevalidate_ssl_le_certificate, ) self.purge = async_to_streamed_response_wrapper( - resources.purge, + cdn_resources.purge, ) self.replace = async_to_streamed_response_wrapper( - resources.replace, + cdn_resources.replace, ) @cached_property def shield(self) -> AsyncShieldResourceWithStreamingResponse: - return AsyncShieldResourceWithStreamingResponse(self._resources.shield) + return AsyncShieldResourceWithStreamingResponse(self._cdn_resources.shield) @cached_property def rules(self) -> AsyncRulesResourceWithStreamingResponse: - return AsyncRulesResourceWithStreamingResponse(self._resources.rules) + return AsyncRulesResourceWithStreamingResponse(self._cdn_resources.rules) diff --git a/src/gcore/resources/cdn/resources/rules.py b/src/gcore/resources/cdn/cdn_resources/rules.py similarity index 98% rename from src/gcore/resources/cdn/resources/rules.py rename to src/gcore/resources/cdn/cdn_resources/rules.py index 88273cf0..7c0424d5 100644 --- a/src/gcore/resources/cdn/resources/rules.py +++ b/src/gcore/resources/cdn/cdn_resources/rules.py @@ -18,9 +18,9 @@ async_to_streamed_response_wrapper, ) from ...._base_client import make_request_options -from ....types.cdn.resources import rule_create_params, rule_update_params, rule_replace_params -from ....types.cdn.resources.cdn_resource_rule import CdnResourceRule -from ....types.cdn.resources.rule_list_response import RuleListResponse +from ....types.cdn.cdn_resources import rule_create_params, rule_update_params, rule_replace_params +from ....types.cdn.cdn_resources.cdn_resource_rule import CDNResourceRule +from ....types.cdn.cdn_resources.rule_list_response import RuleListResponse __all__ = ["RulesResource", "AsyncRulesResource"] @@ -63,7 +63,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceRule: + ) -> CDNResourceRule: """ Create rule @@ -147,7 +147,7 @@ def create( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResourceRule, + cast_to=CDNResourceRule, ) def update( @@ -169,7 +169,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceRule: + ) -> CDNResourceRule: """ Change rule @@ -253,7 +253,7 @@ def update( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResourceRule, + cast_to=CDNResourceRule, ) def list( @@ -338,7 +338,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceRule: + ) -> CDNResourceRule: """ Get rule details @@ -356,7 +356,7 @@ def get( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResourceRule, + cast_to=CDNResourceRule, ) def replace( @@ -378,7 +378,7 @@ def replace( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceRule: + ) -> CDNResourceRule: """ Change rule @@ -462,7 +462,7 @@ def replace( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResourceRule, + cast_to=CDNResourceRule, ) @@ -504,7 +504,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceRule: + ) -> CDNResourceRule: """ Create rule @@ -588,7 +588,7 @@ async def create( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResourceRule, + cast_to=CDNResourceRule, ) async def update( @@ -610,7 +610,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceRule: + ) -> CDNResourceRule: """ Change rule @@ -694,7 +694,7 @@ async def update( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResourceRule, + cast_to=CDNResourceRule, ) async def list( @@ -779,7 +779,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceRule: + ) -> CDNResourceRule: """ Get rule details @@ -797,7 +797,7 @@ async def get( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResourceRule, + cast_to=CDNResourceRule, ) async def replace( @@ -819,7 +819,7 @@ async def replace( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnResourceRule: + ) -> CDNResourceRule: """ Change rule @@ -903,7 +903,7 @@ async def replace( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnResourceRule, + cast_to=CDNResourceRule, ) diff --git a/src/gcore/resources/cdn/resources/shield.py b/src/gcore/resources/cdn/cdn_resources/shield.py similarity index 98% rename from src/gcore/resources/cdn/resources/shield.py rename to src/gcore/resources/cdn/cdn_resources/shield.py index cbb712d5..27c2bf2a 100644 --- a/src/gcore/resources/cdn/resources/shield.py +++ b/src/gcore/resources/cdn/cdn_resources/shield.py @@ -17,8 +17,8 @@ async_to_streamed_response_wrapper, ) from ...._base_client import make_request_options -from ....types.cdn.resources import shield_replace_params -from ....types.cdn.resources.origin_shielding import OriginShielding +from ....types.cdn.cdn_resources import shield_replace_params +from ....types.cdn.cdn_resources.origin_shielding import OriginShielding __all__ = ["ShieldResource", "AsyncShieldResource"] diff --git a/src/gcore/resources/cdn/logs.py b/src/gcore/resources/cdn/logs.py index 7520c6dd..4791a254 100644 --- a/src/gcore/resources/cdn/logs.py +++ b/src/gcore/resources/cdn/logs.py @@ -23,7 +23,7 @@ async_to_custom_streamed_response_wrapper, ) from ...types.cdn import log_list_params, log_download_params -from ...pagination import SyncOffsetPageCdnLogs, AsyncOffsetPageCdnLogs +from ...pagination import SyncOffsetPageCDNLogs, AsyncOffsetPageCDNLogs from ..._base_client import AsyncPaginator, make_request_options from ...types.cdn.cdn_log_entry import Data @@ -110,7 +110,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncOffsetPageCdnLogs[Data]: + ) -> SyncOffsetPageCDNLogs[Data]: """ Get CDN logs for up to 3 days starting today. @@ -298,7 +298,7 @@ def list( """ return self._get_api_list( "/cdn/advanced/v1/logs", - page=SyncOffsetPageCdnLogs[Data], + page=SyncOffsetPageCDNLogs[Data], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -761,7 +761,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[Data, AsyncOffsetPageCdnLogs[Data]]: + ) -> AsyncPaginator[Data, AsyncOffsetPageCDNLogs[Data]]: """ Get CDN logs for up to 3 days starting today. @@ -949,7 +949,7 @@ def list( """ return self._get_api_list( "/cdn/advanced/v1/logs", - page=AsyncOffsetPageCdnLogs[Data], + page=AsyncOffsetPageCDNLogs[Data], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/gcore/resources/cdn/metrics.py b/src/gcore/resources/cdn/metrics.py index d1c551bd..1f2297a4 100644 --- a/src/gcore/resources/cdn/metrics.py +++ b/src/gcore/resources/cdn/metrics.py @@ -18,7 +18,7 @@ ) from ...types.cdn import metric_list_params from ..._base_client import make_request_options -from ...types.cdn.cdn_metrics import CdnMetrics +from ...types.cdn.cdn_metrics import CDNMetrics __all__ = ["MetricsResource", "AsyncMetricsResource"] @@ -58,7 +58,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnMetrics: + ) -> CDNMetrics: """ Get CDN metrics @@ -197,7 +197,7 @@ def list( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnMetrics, + cast_to=CDNMetrics, ) @@ -236,7 +236,7 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CdnMetrics: + ) -> CDNMetrics: """ Get CDN metrics @@ -375,7 +375,7 @@ async def list( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CdnMetrics, + cast_to=CDNMetrics, ) diff --git a/src/gcore/resources/dns/metrics.py b/src/gcore/resources/dns/metrics.py index 3359b610..918583f4 100644 --- a/src/gcore/resources/dns/metrics.py +++ b/src/gcore/resources/dns/metrics.py @@ -58,8 +58,8 @@ def list( Example of success response: ``` - # HELP healthcheck_state The `healthcheck_state` metric reflects the state of a specific monitor after conducting a health check - # TYPE healthcheck_state gauge + HELP healthcheck_state The `healthcheck_state` metric reflects the state of a specific monitor after conducting a health check + TYPE healthcheck_state gauge healthcheck_state{client_id="1",monitor_id="431",monitor_locations="us-east-1,us-west-1",monitor_name="test-monitor-1",monitor_type="http",rrset_name="rrset-name1",rrset_type="rrset-type1",zone_name="zone-name1"} 0 healthcheck_state{client_id="1",monitor_id="4871",monitor_locations="fr-1,fr-2",monitor_name="test-monitor-2",monitor_type="tcp",rrset_name="rrset-name2",rrset_type="rrset-type2",zone_name="zone-name2"} 1 healthcheck_state{client_id="2",monitor_id="7123",monitor_locations="ua-1,ua-2",monitor_name="test-monitor-3",monitor_type="icmp",rrset_name="rrset-name3",rrset_type="rrset-type3",zone_name="zone-name3"} 0 @@ -136,8 +136,8 @@ async def list( Example of success response: ``` - # HELP healthcheck_state The `healthcheck_state` metric reflects the state of a specific monitor after conducting a health check - # TYPE healthcheck_state gauge + HELP healthcheck_state The `healthcheck_state` metric reflects the state of a specific monitor after conducting a health check + TYPE healthcheck_state gauge healthcheck_state{client_id="1",monitor_id="431",monitor_locations="us-east-1,us-west-1",monitor_name="test-monitor-1",monitor_type="http",rrset_name="rrset-name1",rrset_type="rrset-type1",zone_name="zone-name1"} 0 healthcheck_state{client_id="1",monitor_id="4871",monitor_locations="fr-1,fr-2",monitor_name="test-monitor-2",monitor_type="tcp",rrset_name="rrset-name2",rrset_type="rrset-type2",zone_name="zone-name2"} 1 healthcheck_state{client_id="2",monitor_id="7123",monitor_locations="ua-1,ua-2",monitor_name="test-monitor-3",monitor_type="icmp",rrset_name="rrset-name3",rrset_type="rrset-type3",zone_name="zone-name3"} 0 diff --git a/src/gcore/resources/dns/zones/rrsets.py b/src/gcore/resources/dns/zones/rrsets.py index b1ab12a5..736b590d 100644 --- a/src/gcore/resources/dns/zones/rrsets.py +++ b/src/gcore/resources/dns/zones/rrsets.py @@ -72,32 +72,27 @@ def create( Add the RRSet to the zone specified by zoneName, RRSets can be configured to be either dynamic or static. - ### Static RRsets - - Staticly configured RRSets provide DNS responses as is. - - ### Dynamic RRsets - - Dynamic RRSets have picker configuration defined thus it's possible to finely - customize DNS response. Picking rules are defined on the RRSet level as a list - of selectors, filters and mutators. Picker considers different resource records - metadata, requestor IP, and other event-feeds like monitoring. Picker - configuration is an ordered list defined by "pickers" attribute. Requestor IP is - determined by EDNS Client Subnet (ECS) if defined, otherwise - by - client/recursor IP. Selector pickers are used in the specified order until the - first match, in case of match - all next selectors are bypassed. Filters or - mutators are applied to the match according to the order they are specified. + Static RRsets Staticly configured RRSets provide DNS responses as is. + + Dynamic RRsets Dynamic RRSets have picker configuration defined thus it's + possible to finely customize DNS response. Picking rules are defined on the + RRSet level as a list of selectors, filters and mutators. Picker considers + different resource records metadata, requestor IP, and other event-feeds like + monitoring. Picker configuration is an ordered list defined by "pickers" + attribute. Requestor IP is determined by EDNS Client Subnet (ECS) if defined, + otherwise - by client/recursor IP. Selector pickers are used in the specified + order until the first match, in case of match - all next selectors are bypassed. + Filters or mutators are applied to the match according to the order they are + specified. For example, sort records by proximity to user, shuffle based on weights and return not more than 3: `"pickers": [ { "type": "geodistance" }, { "type": "weighted_shuffle" }, { "type": "first_n", "limit": 3 } ]` - #### geodns filter - - A resource record is included in the answer if resource record's metadata - matches requestor info. For each resource record in RRSet, the following - metadata is considered (in the order specified): + geodns filter A resource record is included in the answer if resource record's + metadata matches requestor info. For each resource record in RRSet, the + following metadata is considered (in the order specified): - `ip` - list of network addresses in CIDR format, e.g. `["192.168.15.150/25", "2003:de:2016::/48"]`; @@ -114,91 +109,71 @@ def create( Example: `"pickers": [ { "type": "geodns", "strict": true } ]` - ##### Strict parameter - - `strict: true` means that if no records percolate through the geodns filter it - returns no answers. `strict: false` means that if no records percolate through - the geodns filter, all records are passed over. + Strict parameter `strict: true` means that if no records percolate through the + geodns filter it returns no answers. `strict: false` means that if no records + percolate through the geodns filter, all records are passed over. - #### asn selector - - Resource records which ASN metadata matches ASN of the requestor are picked by - this selector, and passed to the next non-selector picker, if there is no - match - next configured picker starts with all records. + asn selector Resource records which ASN metadata matches ASN of the requestor + are picked by this selector, and passed to the next non-selector picker, if + there is no match - next configured picker starts with all records. Example: `"pickers": [ {"type": "asn"} ]` - #### country selector - - Resource records which country metadata matches country of the requestor are - picked by this selector, and passed to the next non-selector picker, if there is - no match - next configured picker starts with all records. + country selector Resource records which country metadata matches country of the + requestor are picked by this selector, and passed to the next non-selector + picker, if there is no match - next configured picker starts with all records. Example: `"pickers": [ { "type": "country" } ]` - #### continent selector - - Resource records which continent metadata matches continent of the requestor are - picked by this selector, and passed to the next non-selector picker, if there is - no match - next configured picker starts with all records. + continent selector Resource records which continent metadata matches continent + of the requestor are picked by this selector, and passed to the next + non-selector picker, if there is no match - next configured picker starts with + all records. Example: `"pickers": [ { "type": "continent" } ]` - #### region selector - - Resource records which region metadata matches region of the requestor are - picked by this selector, and passed to the next non-selector picker, if there is - no match - next configured picker starts with all records. e.g. `fr-nor` for - France/Normandy. + region selector Resource records which region metadata matches region of the + requestor are picked by this selector, and passed to the next non-selector + picker, if there is no match - next configured picker starts with all records. + e.g. `fr-nor` for France/Normandy. Example: `"pickers": [ { "type": "region" } ]` - #### ip selector - - Resource records which IP metadata matches IP of the requestor are picked by - this selector, and passed to the next non-selector picker, if there is no - match - next configured picker starts with all records. Maximum 100 subnets are - allowed to specify in meta of RR. + ip selector Resource records which IP metadata matches IP of the requestor are + picked by this selector, and passed to the next non-selector picker, if there is + no match - next configured picker starts with all records. Maximum 100 subnets + are allowed to specify in meta of RR. Example: `"pickers": [ { "type": "ip" } ]` - #### default selector - - When enabled, records marked as default are selected: + default selector When enabled, records marked as default are selected: `"meta": {"default": true}`. Example: `"pickers": [ { "type": "geodns", "strict": false }, { "type": "default" }, { "type": "first_n", "limit": 2 } ]` - #### geodistance mutator - - The resource records are rearranged in ascending order based on the distance (in - meters) from requestor to the coordinates specified in latlong metadata. - Distance is calculated using Haversine formula. The "nearest" to the user's IP - RR goes first. The records without latlong metadata come last. e.g. for Berlin - `[52.520008, 13.404954]`.; + geodistance mutator The resource records are rearranged in ascending order based + on the distance (in meters) from requestor to the coordinates specified in + latlong metadata. Distance is calculated using Haversine formula. The "nearest" + to the user's IP RR goes first. The records without latlong metadata come last. + e.g. for Berlin `[52.520008, 13.404954]`.; In this configuration the only "nearest" to the requestor record to be returned: `"pickers": [ { "type": "geodistance" }, { "type": "first_n", "limit": 1 } ]` - #### `weighted_shuffle` mutator - - The resource records are rearranged in random order based on the `weight` - metadata. Default weight (if not specified) is 50. + `weighted_shuffle` mutator The resource records are rearranged in random order + based on the `weight` metadata. Default weight (if not specified) is 50. Example: `"pickers": [ { "type": "weighted_shuffle" } ]` - #### `first_n` filter - - Slices first N (N specified as a limit parameter value) resource records. + `first_n` filter Slices first N (N specified as a limit parameter value) + resource records. Example: `"pickers": [ { "type": "first_n", "limit": 1 } ]` returns only the first resource record. - ##### limit parameter - - Can be a positive value for a specific limit. Use zero or leave it blank to - indicate no limits. + limit parameter Can be a positive value for a specific limit. Use zero or leave + it blank to indicate no limits. Args: resource_records: List of resource record from rrset @@ -528,32 +503,27 @@ async def create( Add the RRSet to the zone specified by zoneName, RRSets can be configured to be either dynamic or static. - ### Static RRsets + Static RRsets Staticly configured RRSets provide DNS responses as is. - Staticly configured RRSets provide DNS responses as is. - - ### Dynamic RRsets - - Dynamic RRSets have picker configuration defined thus it's possible to finely - customize DNS response. Picking rules are defined on the RRSet level as a list - of selectors, filters and mutators. Picker considers different resource records - metadata, requestor IP, and other event-feeds like monitoring. Picker - configuration is an ordered list defined by "pickers" attribute. Requestor IP is - determined by EDNS Client Subnet (ECS) if defined, otherwise - by - client/recursor IP. Selector pickers are used in the specified order until the - first match, in case of match - all next selectors are bypassed. Filters or - mutators are applied to the match according to the order they are specified. + Dynamic RRsets Dynamic RRSets have picker configuration defined thus it's + possible to finely customize DNS response. Picking rules are defined on the + RRSet level as a list of selectors, filters and mutators. Picker considers + different resource records metadata, requestor IP, and other event-feeds like + monitoring. Picker configuration is an ordered list defined by "pickers" + attribute. Requestor IP is determined by EDNS Client Subnet (ECS) if defined, + otherwise - by client/recursor IP. Selector pickers are used in the specified + order until the first match, in case of match - all next selectors are bypassed. + Filters or mutators are applied to the match according to the order they are + specified. For example, sort records by proximity to user, shuffle based on weights and return not more than 3: `"pickers": [ { "type": "geodistance" }, { "type": "weighted_shuffle" }, { "type": "first_n", "limit": 3 } ]` - #### geodns filter - - A resource record is included in the answer if resource record's metadata - matches requestor info. For each resource record in RRSet, the following - metadata is considered (in the order specified): + geodns filter A resource record is included in the answer if resource record's + metadata matches requestor info. For each resource record in RRSet, the + following metadata is considered (in the order specified): - `ip` - list of network addresses in CIDR format, e.g. `["192.168.15.150/25", "2003:de:2016::/48"]`; @@ -570,91 +540,71 @@ async def create( Example: `"pickers": [ { "type": "geodns", "strict": true } ]` - ##### Strict parameter - - `strict: true` means that if no records percolate through the geodns filter it - returns no answers. `strict: false` means that if no records percolate through - the geodns filter, all records are passed over. - - #### asn selector + Strict parameter `strict: true` means that if no records percolate through the + geodns filter it returns no answers. `strict: false` means that if no records + percolate through the geodns filter, all records are passed over. - Resource records which ASN metadata matches ASN of the requestor are picked by - this selector, and passed to the next non-selector picker, if there is no - match - next configured picker starts with all records. + asn selector Resource records which ASN metadata matches ASN of the requestor + are picked by this selector, and passed to the next non-selector picker, if + there is no match - next configured picker starts with all records. Example: `"pickers": [ {"type": "asn"} ]` - #### country selector - - Resource records which country metadata matches country of the requestor are - picked by this selector, and passed to the next non-selector picker, if there is - no match - next configured picker starts with all records. + country selector Resource records which country metadata matches country of the + requestor are picked by this selector, and passed to the next non-selector + picker, if there is no match - next configured picker starts with all records. Example: `"pickers": [ { "type": "country" } ]` - #### continent selector - - Resource records which continent metadata matches continent of the requestor are - picked by this selector, and passed to the next non-selector picker, if there is - no match - next configured picker starts with all records. + continent selector Resource records which continent metadata matches continent + of the requestor are picked by this selector, and passed to the next + non-selector picker, if there is no match - next configured picker starts with + all records. Example: `"pickers": [ { "type": "continent" } ]` - #### region selector - - Resource records which region metadata matches region of the requestor are - picked by this selector, and passed to the next non-selector picker, if there is - no match - next configured picker starts with all records. e.g. `fr-nor` for - France/Normandy. + region selector Resource records which region metadata matches region of the + requestor are picked by this selector, and passed to the next non-selector + picker, if there is no match - next configured picker starts with all records. + e.g. `fr-nor` for France/Normandy. Example: `"pickers": [ { "type": "region" } ]` - #### ip selector - - Resource records which IP metadata matches IP of the requestor are picked by - this selector, and passed to the next non-selector picker, if there is no - match - next configured picker starts with all records. Maximum 100 subnets are - allowed to specify in meta of RR. + ip selector Resource records which IP metadata matches IP of the requestor are + picked by this selector, and passed to the next non-selector picker, if there is + no match - next configured picker starts with all records. Maximum 100 subnets + are allowed to specify in meta of RR. Example: `"pickers": [ { "type": "ip" } ]` - #### default selector - - When enabled, records marked as default are selected: + default selector When enabled, records marked as default are selected: `"meta": {"default": true}`. Example: `"pickers": [ { "type": "geodns", "strict": false }, { "type": "default" }, { "type": "first_n", "limit": 2 } ]` - #### geodistance mutator - - The resource records are rearranged in ascending order based on the distance (in - meters) from requestor to the coordinates specified in latlong metadata. - Distance is calculated using Haversine formula. The "nearest" to the user's IP - RR goes first. The records without latlong metadata come last. e.g. for Berlin - `[52.520008, 13.404954]`.; + geodistance mutator The resource records are rearranged in ascending order based + on the distance (in meters) from requestor to the coordinates specified in + latlong metadata. Distance is calculated using Haversine formula. The "nearest" + to the user's IP RR goes first. The records without latlong metadata come last. + e.g. for Berlin `[52.520008, 13.404954]`.; In this configuration the only "nearest" to the requestor record to be returned: `"pickers": [ { "type": "geodistance" }, { "type": "first_n", "limit": 1 } ]` - #### `weighted_shuffle` mutator - - The resource records are rearranged in random order based on the `weight` - metadata. Default weight (if not specified) is 50. + `weighted_shuffle` mutator The resource records are rearranged in random order + based on the `weight` metadata. Default weight (if not specified) is 50. Example: `"pickers": [ { "type": "weighted_shuffle" } ]` - #### `first_n` filter - - Slices first N (N specified as a limit parameter value) resource records. + `first_n` filter Slices first N (N specified as a limit parameter value) + resource records. Example: `"pickers": [ { "type": "first_n", "limit": 1 } ]` returns only the first resource record. - ##### limit parameter - - Can be a positive value for a specific limit. Use zero or leave it blank to - indicate no limits. + limit parameter Can be a positive value for a specific limit. Use zero or leave + it blank to indicate no limits. Args: resource_records: List of resource record from rrset diff --git a/src/gcore/resources/streaming/playlists.py b/src/gcore/resources/streaming/playlists.py index fe1f49db..28f15c1a 100644 --- a/src/gcore/resources/streaming/playlists.py +++ b/src/gcore/resources/streaming/playlists.py @@ -173,6 +173,7 @@ def create( This URL is a link to the main manifest. But you can also manually specify suffix-options that will allow you to change the manifest to your request: + `/playlists/{client_id}_{playlist_id}/master[-cmaf][-min-N][-max-N][-img][-(h264|hevc|av1)].m3u8` Please see the details in `hls_url` attribute of /videos/{id} method. @@ -308,6 +309,7 @@ def update( This URL is a link to the main manifest. But you can also manually specify suffix-options that will allow you to change the manifest to your request: + `/playlists/{client_id}_{playlist_id}/master[-cmaf][-min-N][-max-N][-img][-(h264|hevc|av1)].m3u8` Please see the details in `hls_url` attribute of /videos/{id} method. @@ -662,6 +664,7 @@ async def create( This URL is a link to the main manifest. But you can also manually specify suffix-options that will allow you to change the manifest to your request: + `/playlists/{client_id}_{playlist_id}/master[-cmaf][-min-N][-max-N][-img][-(h264|hevc|av1)].m3u8` Please see the details in `hls_url` attribute of /videos/{id} method. @@ -797,6 +800,7 @@ async def update( This URL is a link to the main manifest. But you can also manually specify suffix-options that will allow you to change the manifest to your request: + `/playlists/{client_id}_{playlist_id}/master[-cmaf][-min-N][-max-N][-img][-(h264|hevc|av1)].m3u8` Please see the details in `hls_url` attribute of /videos/{id} method. diff --git a/src/gcore/resources/streaming/statistics.py b/src/gcore/resources/streaming/statistics.py index aa67b732..234766df 100644 --- a/src/gcore/resources/streaming/statistics.py +++ b/src/gcore/resources/streaming/statistics.py @@ -56,12 +56,12 @@ from ...types.streaming.views_by_referer import ViewsByReferer from ...types.streaming.max_stream_series import MaxStreamSeries from ...types.streaming.views_by_hostname import ViewsByHostname -from ...types.streaming.unique_viewers_cdn import UniqueViewersCdn +from ...types.streaming.unique_viewers_cdn import UniqueViewersCDN from ...types.streaming.vod_statistics_series import VodStatisticsSeries from ...types.streaming.views_by_operating_system import ViewsByOperatingSystem from ...types.streaming.vod_total_stream_duration_series import VodTotalStreamDurationSeries from ...types.streaming.statistic_get_live_unique_viewers_response import StatisticGetLiveUniqueViewersResponse -from ...types.streaming.statistic_get_vod_watch_time_total_cdn_response import StatisticGetVodWatchTimeTotalCdnResponse +from ...types.streaming.statistic_get_vod_watch_time_total_cdn_response import StatisticGetVodWatchTimeTotalCDNResponse __all__ = ["StatisticsResource", "AsyncStatisticsResource"] @@ -275,7 +275,7 @@ def get_live_watch_time_cdn( "stream_id": stream_id, "to": to, }, - statistic_get_live_watch_time_cdn_params.StatisticGetLiveWatchTimeCdnParams, + statistic_get_live_watch_time_cdn_params.StatisticGetLiveWatchTimeCDNParams, ), ), cast_to=StreamSeries, @@ -336,7 +336,7 @@ def get_live_watch_time_total_cdn( "stream_id": stream_id, "to": to, }, - statistic_get_live_watch_time_total_cdn_params.StatisticGetLiveWatchTimeTotalCdnParams, + statistic_get_live_watch_time_total_cdn_params.StatisticGetLiveWatchTimeTotalCDNParams, ), ), cast_to=VodTotalStreamDurationSeries, @@ -645,7 +645,7 @@ def get_unique_viewers_cdn( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> UniqueViewersCdn: + ) -> UniqueViewersCDN: """Сounts the number of unique viewers of a video entity over CDN. It doesn't @@ -726,10 +726,10 @@ def get_unique_viewers_cdn( "id": id, "type": type, }, - statistic_get_unique_viewers_cdn_params.StatisticGetUniqueViewersCdnParams, + statistic_get_unique_viewers_cdn_params.StatisticGetUniqueViewersCDNParams, ), ), - cast_to=UniqueViewersCdn, + cast_to=UniqueViewersCDN, ) def get_views( @@ -1356,7 +1356,7 @@ def get_vod_unique_viewers_cdn( "granularity": granularity, "slug": slug, }, - statistic_get_vod_unique_viewers_cdn_params.StatisticGetVodUniqueViewersCdnParams, + statistic_get_vod_unique_viewers_cdn_params.StatisticGetVodUniqueViewersCDNParams, ), ), cast_to=VodStatisticsSeries, @@ -1425,7 +1425,7 @@ def get_vod_watch_time_cdn( "slug": slug, "to": to, }, - statistic_get_vod_watch_time_cdn_params.StatisticGetVodWatchTimeCdnParams, + statistic_get_vod_watch_time_cdn_params.StatisticGetVodWatchTimeCDNParams, ), ), cast_to=VodStatisticsSeries, @@ -1444,7 +1444,7 @@ def get_vod_watch_time_total_cdn( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> StatisticGetVodWatchTimeTotalCdnResponse: + ) -> StatisticGetVodWatchTimeTotalCDNResponse: """Calculates the total duration of video watching in minutes. Views of only those @@ -1486,10 +1486,10 @@ def get_vod_watch_time_total_cdn( "slug": slug, "to": to, }, - statistic_get_vod_watch_time_total_cdn_params.StatisticGetVodWatchTimeTotalCdnParams, + statistic_get_vod_watch_time_total_cdn_params.StatisticGetVodWatchTimeTotalCDNParams, ), ), - cast_to=StatisticGetVodWatchTimeTotalCdnResponse, + cast_to=StatisticGetVodWatchTimeTotalCDNResponse, ) @@ -1702,7 +1702,7 @@ async def get_live_watch_time_cdn( "stream_id": stream_id, "to": to, }, - statistic_get_live_watch_time_cdn_params.StatisticGetLiveWatchTimeCdnParams, + statistic_get_live_watch_time_cdn_params.StatisticGetLiveWatchTimeCDNParams, ), ), cast_to=StreamSeries, @@ -1763,7 +1763,7 @@ async def get_live_watch_time_total_cdn( "stream_id": stream_id, "to": to, }, - statistic_get_live_watch_time_total_cdn_params.StatisticGetLiveWatchTimeTotalCdnParams, + statistic_get_live_watch_time_total_cdn_params.StatisticGetLiveWatchTimeTotalCDNParams, ), ), cast_to=VodTotalStreamDurationSeries, @@ -2072,7 +2072,7 @@ async def get_unique_viewers_cdn( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> UniqueViewersCdn: + ) -> UniqueViewersCDN: """Сounts the number of unique viewers of a video entity over CDN. It doesn't @@ -2153,10 +2153,10 @@ async def get_unique_viewers_cdn( "id": id, "type": type, }, - statistic_get_unique_viewers_cdn_params.StatisticGetUniqueViewersCdnParams, + statistic_get_unique_viewers_cdn_params.StatisticGetUniqueViewersCDNParams, ), ), - cast_to=UniqueViewersCdn, + cast_to=UniqueViewersCDN, ) async def get_views( @@ -2783,7 +2783,7 @@ async def get_vod_unique_viewers_cdn( "granularity": granularity, "slug": slug, }, - statistic_get_vod_unique_viewers_cdn_params.StatisticGetVodUniqueViewersCdnParams, + statistic_get_vod_unique_viewers_cdn_params.StatisticGetVodUniqueViewersCDNParams, ), ), cast_to=VodStatisticsSeries, @@ -2852,7 +2852,7 @@ async def get_vod_watch_time_cdn( "slug": slug, "to": to, }, - statistic_get_vod_watch_time_cdn_params.StatisticGetVodWatchTimeCdnParams, + statistic_get_vod_watch_time_cdn_params.StatisticGetVodWatchTimeCDNParams, ), ), cast_to=VodStatisticsSeries, @@ -2871,7 +2871,7 @@ async def get_vod_watch_time_total_cdn( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> StatisticGetVodWatchTimeTotalCdnResponse: + ) -> StatisticGetVodWatchTimeTotalCDNResponse: """Calculates the total duration of video watching in minutes. Views of only those @@ -2913,10 +2913,10 @@ async def get_vod_watch_time_total_cdn( "slug": slug, "to": to, }, - statistic_get_vod_watch_time_total_cdn_params.StatisticGetVodWatchTimeTotalCdnParams, + statistic_get_vod_watch_time_total_cdn_params.StatisticGetVodWatchTimeTotalCDNParams, ), ), - cast_to=StatisticGetVodWatchTimeTotalCdnResponse, + cast_to=StatisticGetVodWatchTimeTotalCDNResponse, ) diff --git a/src/gcore/resources/waap/domains/statistics.py b/src/gcore/resources/waap/domains/statistics.py index 94514578..225b0f77 100644 --- a/src/gcore/resources/waap/domains/statistics.py +++ b/src/gcore/resources/waap/domains/statistics.py @@ -2,6 +2,7 @@ from __future__ import annotations +import typing_extensions from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal @@ -187,7 +188,7 @@ def get_events_aggregated( domain_id: int, *, start: str, - action: Optional[List[Literal["block", "captcha", "handshake", "monitor"]]] | Omit = omit, + action: Optional[List[Literal["allow", "block", "captcha", "handshake"]]] | Omit = omit, end: Optional[str] | Omit = omit, ip: Optional[SequenceNotStr[str]] | Omit = omit, reference_id: Optional[SequenceNotStr[str]] | Omit = omit, @@ -287,6 +288,7 @@ def get_request_details( cast_to=WaapRequestDetails, ) + @typing_extensions.deprecated("deprecated") def get_requests_series( self, domain_id: int, @@ -334,8 +336,11 @@ def get_requests_series( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncOffsetPage[WaapRequestSummary]: - """ - Retrieve a domain's requests data. + """Retrieve a domain's requests data. + + Deprecated. Use + [GET /v1/analytics/requests](/docs/api-reference/waap/analytics/get-request-log-data) + instead. Args: domain_id: The domain ID @@ -609,7 +614,7 @@ async def get_events_aggregated( domain_id: int, *, start: str, - action: Optional[List[Literal["block", "captcha", "handshake", "monitor"]]] | Omit = omit, + action: Optional[List[Literal["allow", "block", "captcha", "handshake"]]] | Omit = omit, end: Optional[str] | Omit = omit, ip: Optional[SequenceNotStr[str]] | Omit = omit, reference_id: Optional[SequenceNotStr[str]] | Omit = omit, @@ -709,6 +714,7 @@ async def get_request_details( cast_to=WaapRequestDetails, ) + @typing_extensions.deprecated("deprecated") def get_requests_series( self, domain_id: int, @@ -756,8 +762,11 @@ def get_requests_series( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[WaapRequestSummary, AsyncOffsetPage[WaapRequestSummary]]: - """ - Retrieve a domain's requests data. + """Retrieve a domain's requests data. + + Deprecated. Use + [GET /v1/analytics/requests](/docs/api-reference/waap/analytics/get-request-log-data) + instead. Args: domain_id: The domain ID @@ -897,8 +906,10 @@ def __init__(self, statistics: StatisticsResource) -> None: self.get_request_details = to_raw_response_wrapper( statistics.get_request_details, ) - self.get_requests_series = to_raw_response_wrapper( - statistics.get_requests_series, + self.get_requests_series = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + statistics.get_requests_series, # pyright: ignore[reportDeprecated], + ) ) self.get_traffic_series = to_raw_response_wrapper( statistics.get_traffic_series, @@ -921,8 +932,10 @@ def __init__(self, statistics: AsyncStatisticsResource) -> None: self.get_request_details = async_to_raw_response_wrapper( statistics.get_request_details, ) - self.get_requests_series = async_to_raw_response_wrapper( - statistics.get_requests_series, + self.get_requests_series = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + statistics.get_requests_series, # pyright: ignore[reportDeprecated], + ) ) self.get_traffic_series = async_to_raw_response_wrapper( statistics.get_traffic_series, @@ -945,8 +958,10 @@ def __init__(self, statistics: StatisticsResource) -> None: self.get_request_details = to_streamed_response_wrapper( statistics.get_request_details, ) - self.get_requests_series = to_streamed_response_wrapper( - statistics.get_requests_series, + self.get_requests_series = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + statistics.get_requests_series, # pyright: ignore[reportDeprecated], + ) ) self.get_traffic_series = to_streamed_response_wrapper( statistics.get_traffic_series, @@ -969,8 +984,10 @@ def __init__(self, statistics: AsyncStatisticsResource) -> None: self.get_request_details = async_to_streamed_response_wrapper( statistics.get_request_details, ) - self.get_requests_series = async_to_streamed_response_wrapper( - statistics.get_requests_series, + self.get_requests_series = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + statistics.get_requests_series, # pyright: ignore[reportDeprecated], + ) ) self.get_traffic_series = async_to_streamed_response_wrapper( statistics.get_traffic_series, diff --git a/src/gcore/types/cdn/__init__.py b/src/gcore/types/cdn/__init__.py index 8cd6fefc..92895e33 100644 --- a/src/gcore/types/cdn/__init__.py +++ b/src/gcore/types/cdn/__init__.py @@ -4,11 +4,11 @@ from .ssl_detail import SslDetail as SslDetail from .aws_regions import AwsRegions as AwsRegions -from .cdn_account import CdnAccount as CdnAccount -from .cdn_metrics import CdnMetrics as CdnMetrics -from .cdn_resource import CdnResource as CdnResource +from .cdn_account import CDNAccount as CDNAccount +from .cdn_metrics import CDNMetrics as CDNMetrics +from .cdn_resource import CDNResource as CDNResource from .purge_status import PurgeStatus as PurgeStatus -from .cdn_log_entry import CdnLogEntry as CdnLogEntry +from .cdn_log_entry import CDNLogEntry as CDNLogEntry from .origin_groups import OriginGroups as OriginGroups from .rule_template import RuleTemplate as RuleTemplate from .ca_certificate import CaCertificate as CaCertificate @@ -17,49 +17,49 @@ from .log_list_params import LogListParams as LogListParams from .ssl_detail_list import SslDetailList as SslDetailList from .network_capacity import NetworkCapacity as NetworkCapacity -from .cdn_resource_list import CdnResourceList as CdnResourceList -from .cdn_account_limits import CdnAccountLimits as CdnAccountLimits -from .cdn_metrics_groups import CdnMetricsGroups as CdnMetricsGroups -from .cdn_metrics_values import CdnMetricsValues as CdnMetricsValues +from .cdn_resource_list import CDNResourceList as CDNResourceList +from .cdn_account_limits import CDNAccountLimits as CDNAccountLimits +from .cdn_metrics_groups import CDNMetricsGroups as CDNMetricsGroups +from .cdn_metrics_values import CDNMetricsValues as CDNMetricsValues from .metric_list_params import MetricListParams as MetricListParams from .origin_groups_list import OriginGroupsList as OriginGroupsList from .rule_template_list import RuleTemplateList as RuleTemplateList from .ssl_request_status import SslRequestStatus as SslRequestStatus from .usage_series_stats import UsageSeriesStats as UsageSeriesStats from .ca_certificate_list import CaCertificateList as CaCertificateList -from .cdn_audit_log_entry import CdnAuditLogEntry as CdnAuditLogEntry +from .cdn_audit_log_entry import CDNAuditLogEntry as CDNAuditLogEntry from .log_download_params import LogDownloadParams as LogDownloadParams from .public_network_list import PublicNetworkList as PublicNetworkList from .ip_range_list_params import IPRangeListParams as IPRangeListParams -from .resource_list_params import ResourceListParams as ResourceListParams from .resource_usage_stats import ResourceUsageStats as ResourceUsageStats from .shield_list_response import ShieldListResponse as ShieldListResponse from .audit_log_list_params import AuditLogListParams as AuditLogListParams from .logs_aggregated_stats import LogsAggregatedStats as LogsAggregatedStats -from .resource_purge_params import ResourcePurgeParams as ResourcePurgeParams -from .cdn_available_features import CdnAvailableFeatures as CdnAvailableFeatures -from .resource_create_params import ResourceCreateParams as ResourceCreateParams -from .resource_update_params import ResourceUpdateParams as ResourceUpdateParams +from .cdn_available_features import CDNAvailableFeatures as CDNAvailableFeatures from .certificate_list_params import CertificateListParams as CertificateListParams -from .resource_replace_params import ResourceReplaceParams as ResourceReplaceParams from .shield_aggregated_stats import ShieldAggregatedStats as ShieldAggregatedStats +from .cdn_resource_list_params import CDNResourceListParams as CDNResourceListParams from .ip_range_list_ips_params import IPRangeListIPsParams as IPRangeListIPsParams from .logs_uploader_validation import LogsUploaderValidation as LogsUploaderValidation from .origin_group_list_params import OriginGroupListParams as OriginGroupListParams -from .resource_prefetch_params import ResourcePrefetchParams as ResourcePrefetchParams -from .cdn_update_account_params import CdnUpdateAccountParams as CdnUpdateAccountParams +from .cdn_resource_purge_params import CDNResourcePurgeParams as CDNResourcePurgeParams +from .cdn_update_account_params import CDNUpdateAccountParams as CDNUpdateAccountParams from .certificate_create_params import CertificateCreateParams as CertificateCreateParams from .resource_aggregated_stats import ResourceAggregatedStats as ResourceAggregatedStats +from .cdn_resource_create_params import CDNResourceCreateParams as CDNResourceCreateParams +from .cdn_resource_update_params import CDNResourceUpdateParams as CDNResourceUpdateParams from .certificate_replace_params import CertificateReplaceParams as CertificateReplaceParams from .origin_group_create_params import OriginGroupCreateParams as OriginGroupCreateParams from .origin_group_update_params import OriginGroupUpdateParams as OriginGroupUpdateParams +from .cdn_resource_replace_params import CDNResourceReplaceParams as CDNResourceReplaceParams from .origin_group_replace_params import OriginGroupReplaceParams as OriginGroupReplaceParams from .rule_template_create_params import RuleTemplateCreateParams as RuleTemplateCreateParams from .rule_template_update_params import RuleTemplateUpdateParams as RuleTemplateUpdateParams +from .cdn_resource_prefetch_params import CDNResourcePrefetchParams as CDNResourcePrefetchParams from .rule_template_replace_params import RuleTemplateReplaceParams as RuleTemplateReplaceParams from .certificate_get_status_params import CertificateGetStatusParams as CertificateGetStatusParams -from .cdn_list_purge_statuses_params import CdnListPurgeStatusesParams as CdnListPurgeStatusesParams -from .cdn_list_purge_statuses_response import CdnListPurgeStatusesResponse as CdnListPurgeStatusesResponse +from .cdn_list_purge_statuses_params import CDNListPurgeStatusesParams as CDNListPurgeStatusesParams +from .cdn_list_purge_statuses_response import CDNListPurgeStatusesResponse as CDNListPurgeStatusesResponse from .trusted_ca_certificate_list_params import TrustedCaCertificateListParams as TrustedCaCertificateListParams from .trusted_ca_certificate_create_params import TrustedCaCertificateCreateParams as TrustedCaCertificateCreateParams from .trusted_ca_certificate_replace_params import ( diff --git a/src/gcore/types/cdn/cdn_account.py b/src/gcore/types/cdn/cdn_account.py index a1a34e7e..c9bccffb 100644 --- a/src/gcore/types/cdn/cdn_account.py +++ b/src/gcore/types/cdn/cdn_account.py @@ -4,7 +4,7 @@ from ..._models import BaseModel -__all__ = ["CdnAccount", "Service"] +__all__ = ["CDNAccount", "Service"] class Service(BaseModel): @@ -38,7 +38,7 @@ class Service(BaseModel): """Date of the last CDN service status update (ISO 8601/RFC 3339 format, UTC.)""" -class CdnAccount(BaseModel): +class CDNAccount(BaseModel): id: Optional[int] = None """Account ID.""" diff --git a/src/gcore/types/cdn/cdn_account_limits.py b/src/gcore/types/cdn/cdn_account_limits.py index efaf384d..cb398ffa 100644 --- a/src/gcore/types/cdn/cdn_account_limits.py +++ b/src/gcore/types/cdn/cdn_account_limits.py @@ -4,10 +4,10 @@ from ..._models import BaseModel -__all__ = ["CdnAccountLimits"] +__all__ = ["CDNAccountLimits"] -class CdnAccountLimits(BaseModel): +class CDNAccountLimits(BaseModel): id: Optional[int] = None """Account ID.""" diff --git a/src/gcore/types/cdn/cdn_audit_log_entry.py b/src/gcore/types/cdn/cdn_audit_log_entry.py index 28064cb6..ec56b787 100644 --- a/src/gcore/types/cdn/cdn_audit_log_entry.py +++ b/src/gcore/types/cdn/cdn_audit_log_entry.py @@ -4,7 +4,7 @@ from ..._models import BaseModel -__all__ = ["CdnAuditLogEntry", "Action"] +__all__ = ["CDNAuditLogEntry", "Action"] class Action(BaseModel): @@ -25,7 +25,7 @@ class Action(BaseModel): """JSON representation of object before the request.""" -class CdnAuditLogEntry(BaseModel): +class CDNAuditLogEntry(BaseModel): id: Optional[int] = None """Activity logs record ID.""" diff --git a/src/gcore/types/cdn/cdn_available_features.py b/src/gcore/types/cdn/cdn_available_features.py index dead1cdc..ffeaf299 100644 --- a/src/gcore/types/cdn/cdn_available_features.py +++ b/src/gcore/types/cdn/cdn_available_features.py @@ -4,7 +4,7 @@ from ..._models import BaseModel -__all__ = ["CdnAvailableFeatures", "FreeFeature", "PaidFeature"] +__all__ = ["CDNAvailableFeatures", "FreeFeature", "PaidFeature"] class FreeFeature(BaseModel): @@ -35,7 +35,7 @@ class PaidFeature(BaseModel): """Internal feature activation ID.""" -class CdnAvailableFeatures(BaseModel): +class CDNAvailableFeatures(BaseModel): id: Optional[int] = None """Account ID.""" diff --git a/src/gcore/types/cdn/cdn_list_purge_statuses_params.py b/src/gcore/types/cdn/cdn_list_purge_statuses_params.py index 3c725a88..a0c3227b 100644 --- a/src/gcore/types/cdn/cdn_list_purge_statuses_params.py +++ b/src/gcore/types/cdn/cdn_list_purge_statuses_params.py @@ -4,10 +4,10 @@ from typing_extensions import TypedDict -__all__ = ["CdnListPurgeStatusesParams"] +__all__ = ["CDNListPurgeStatusesParams"] -class CdnListPurgeStatusesParams(TypedDict, total=False): +class CDNListPurgeStatusesParams(TypedDict, total=False): cname: str """Purges associated with a specific resource CNAME. diff --git a/src/gcore/types/cdn/cdn_list_purge_statuses_response.py b/src/gcore/types/cdn/cdn_list_purge_statuses_response.py index 1dec8100..e0a38e7c 100644 --- a/src/gcore/types/cdn/cdn_list_purge_statuses_response.py +++ b/src/gcore/types/cdn/cdn_list_purge_statuses_response.py @@ -5,6 +5,6 @@ from .purge_status import PurgeStatus -__all__ = ["CdnListPurgeStatusesResponse"] +__all__ = ["CDNListPurgeStatusesResponse"] -CdnListPurgeStatusesResponse: TypeAlias = List[PurgeStatus] +CDNListPurgeStatusesResponse: TypeAlias = List[PurgeStatus] diff --git a/src/gcore/types/cdn/cdn_log_entry.py b/src/gcore/types/cdn/cdn_log_entry.py index 017462cd..b9d193f9 100644 --- a/src/gcore/types/cdn/cdn_log_entry.py +++ b/src/gcore/types/cdn/cdn_log_entry.py @@ -4,7 +4,7 @@ from ..._models import BaseModel -__all__ = ["CdnLogEntry", "Data", "Meta"] +__all__ = ["CDNLogEntry", "Data", "Meta"] class Data(BaseModel): @@ -64,7 +64,7 @@ class Meta(BaseModel): """Total number of records which match given parameters.""" -class CdnLogEntry(BaseModel): +class CDNLogEntry(BaseModel): data: Optional[List[Data]] = None """Contains requested logs.""" diff --git a/src/gcore/types/cdn/cdn_metrics.py b/src/gcore/types/cdn/cdn_metrics.py index de50e377..26537ff3 100644 --- a/src/gcore/types/cdn/cdn_metrics.py +++ b/src/gcore/types/cdn/cdn_metrics.py @@ -4,15 +4,15 @@ from typing_extensions import TypeAlias from ..._models import BaseModel -from .cdn_metrics_groups import CdnMetricsGroups -from .cdn_metrics_values import CdnMetricsValues +from .cdn_metrics_groups import CDNMetricsGroups +from .cdn_metrics_values import CDNMetricsValues -__all__ = ["CdnMetrics", "Data"] +__all__ = ["CDNMetrics", "Data"] -Data: TypeAlias = Union[CdnMetricsValues, CdnMetricsGroups] +Data: TypeAlias = Union[CDNMetricsValues, CDNMetricsGroups] -class CdnMetrics(BaseModel): +class CDNMetrics(BaseModel): data: Optional[Data] = None """ If no grouping was requested then "data" holds an array of metric values. If at diff --git a/src/gcore/types/cdn/cdn_metrics_groups.py b/src/gcore/types/cdn/cdn_metrics_groups.py index e808f0bd..a88712d6 100644 --- a/src/gcore/types/cdn/cdn_metrics_groups.py +++ b/src/gcore/types/cdn/cdn_metrics_groups.py @@ -3,11 +3,11 @@ from typing import Optional from ..._models import BaseModel -from .cdn_metrics_values import CdnMetricsValues +from .cdn_metrics_values import CDNMetricsValues -__all__ = ["CdnMetricsGroups"] +__all__ = ["CDNMetricsGroups"] -class CdnMetricsGroups(BaseModel): - group: Optional[CdnMetricsValues] = None +class CDNMetricsGroups(BaseModel): + group: Optional[CDNMetricsValues] = None """List of requested metrics sorted by timestamp in ascending order.""" diff --git a/src/gcore/types/cdn/cdn_metrics_values.py b/src/gcore/types/cdn/cdn_metrics_values.py index d436ae54..cd63a18c 100644 --- a/src/gcore/types/cdn/cdn_metrics_values.py +++ b/src/gcore/types/cdn/cdn_metrics_values.py @@ -5,10 +5,10 @@ from ..._models import BaseModel -__all__ = ["CdnMetricsValues", "CdnMetricsValueItem"] +__all__ = ["CDNMetricsValues", "CDNMetricsValueItem"] -class CdnMetricsValueItem(BaseModel): +class CDNMetricsValueItem(BaseModel): metric: Optional[float] = None """Metrics value.""" @@ -16,4 +16,4 @@ class CdnMetricsValueItem(BaseModel): """Start timestamp of interval.""" -CdnMetricsValues: TypeAlias = List[CdnMetricsValueItem] +CDNMetricsValues: TypeAlias = List[CDNMetricsValueItem] diff --git a/src/gcore/types/cdn/cdn_resource.py b/src/gcore/types/cdn/cdn_resource.py index a1066729..0bcef26f 100644 --- a/src/gcore/types/cdn/cdn_resource.py +++ b/src/gcore/types/cdn/cdn_resource.py @@ -8,7 +8,7 @@ from ..._models import BaseModel __all__ = [ - "CdnResource", + "CDNResource", "Options", "OptionsAllowedHTTPMethods", "OptionsBotProtection", @@ -790,6 +790,7 @@ class OptionsIPAddressACL(BaseModel): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1592,6 +1593,9 @@ class OptionsUserAgentACL(BaseModel): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1823,8 +1827,9 @@ class Options(BaseModel): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -2015,7 +2020,7 @@ class Options(BaseModel): """Enables or disables WebSockets connections to an origin server.""" -class CdnResource(BaseModel): +class CDNResource(BaseModel): id: Optional[int] = None """CDN resource ID.""" diff --git a/src/gcore/types/cdn/resource_create_params.py b/src/gcore/types/cdn/cdn_resource_create_params.py similarity index 99% rename from src/gcore/types/cdn/resource_create_params.py rename to src/gcore/types/cdn/cdn_resource_create_params.py index 09c122d2..a7f775a8 100644 --- a/src/gcore/types/cdn/resource_create_params.py +++ b/src/gcore/types/cdn/cdn_resource_create_params.py @@ -9,7 +9,7 @@ from ..._utils import PropertyInfo __all__ = [ - "ResourceCreateParams", + "CDNResourceCreateParams", "Options", "OptionsAllowedHTTPMethods", "OptionsBotProtection", @@ -71,7 +71,7 @@ ] -class ResourceCreateParams(TypedDict, total=False): +class CDNResourceCreateParams(TypedDict, total=False): cname: Required[str] """Delivery domains that will be used for content delivery through a CDN. @@ -913,6 +913,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1713,6 +1714,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1944,8 +1948,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/cdn_resource_list.py b/src/gcore/types/cdn/cdn_resource_list.py index cfbed20c..8146c2e7 100644 --- a/src/gcore/types/cdn/cdn_resource_list.py +++ b/src/gcore/types/cdn/cdn_resource_list.py @@ -3,8 +3,8 @@ from typing import List from typing_extensions import TypeAlias -from .cdn_resource import CdnResource +from .cdn_resource import CDNResource -__all__ = ["CdnResourceList"] +__all__ = ["CDNResourceList"] -CdnResourceList: TypeAlias = List[CdnResource] +CDNResourceList: TypeAlias = List[CDNResource] diff --git a/src/gcore/types/cdn/resource_list_params.py b/src/gcore/types/cdn/cdn_resource_list_params.py similarity index 96% rename from src/gcore/types/cdn/resource_list_params.py rename to src/gcore/types/cdn/cdn_resource_list_params.py index 24c26506..98c70e08 100644 --- a/src/gcore/types/cdn/resource_list_params.py +++ b/src/gcore/types/cdn/cdn_resource_list_params.py @@ -6,10 +6,10 @@ from ..._utils import PropertyInfo -__all__ = ["ResourceListParams"] +__all__ = ["CDNResourceListParams"] -class ResourceListParams(TypedDict, total=False): +class CDNResourceListParams(TypedDict, total=False): cname: str """Delivery domain (CNAME) of the CDN resource.""" diff --git a/src/gcore/types/cdn/resource_prefetch_params.py b/src/gcore/types/cdn/cdn_resource_prefetch_params.py similarity index 80% rename from src/gcore/types/cdn/resource_prefetch_params.py rename to src/gcore/types/cdn/cdn_resource_prefetch_params.py index 1fc88a63..1d3c0aa0 100644 --- a/src/gcore/types/cdn/resource_prefetch_params.py +++ b/src/gcore/types/cdn/cdn_resource_prefetch_params.py @@ -6,10 +6,10 @@ from ..._types import SequenceNotStr -__all__ = ["ResourcePrefetchParams"] +__all__ = ["CDNResourcePrefetchParams"] -class ResourcePrefetchParams(TypedDict, total=False): +class CDNResourcePrefetchParams(TypedDict, total=False): paths: Required[SequenceNotStr[str]] """Paths to files that should be pre-populated to the CDN. diff --git a/src/gcore/types/cdn/resource_purge_params.py b/src/gcore/types/cdn/cdn_resource_purge_params.py similarity index 94% rename from src/gcore/types/cdn/resource_purge_params.py rename to src/gcore/types/cdn/cdn_resource_purge_params.py index 0a930c50..aa885a05 100644 --- a/src/gcore/types/cdn/resource_purge_params.py +++ b/src/gcore/types/cdn/cdn_resource_purge_params.py @@ -7,7 +7,7 @@ from ..._types import SequenceNotStr -__all__ = ["ResourcePurgeParams", "PurgeByURL", "PurgeByPattern", "PurgeAllCache"] +__all__ = ["CDNResourcePurgeParams", "PurgeByURL", "PurgeByPattern", "PurgeAllCache"] class PurgeByURL(TypedDict, total=False): @@ -68,4 +68,4 @@ class PurgeAllCache(TypedDict, total=False): """ -ResourcePurgeParams: TypeAlias = Union[PurgeByURL, PurgeByPattern, PurgeAllCache] +CDNResourcePurgeParams: TypeAlias = Union[PurgeByURL, PurgeByPattern, PurgeAllCache] diff --git a/src/gcore/types/cdn/resource_replace_params.py b/src/gcore/types/cdn/cdn_resource_replace_params.py similarity index 99% rename from src/gcore/types/cdn/resource_replace_params.py rename to src/gcore/types/cdn/cdn_resource_replace_params.py index e1ab08b8..0503cf07 100644 --- a/src/gcore/types/cdn/resource_replace_params.py +++ b/src/gcore/types/cdn/cdn_resource_replace_params.py @@ -9,7 +9,7 @@ from ..._utils import PropertyInfo __all__ = [ - "ResourceReplaceParams", + "CDNResourceReplaceParams", "Options", "OptionsAllowedHTTPMethods", "OptionsBotProtection", @@ -71,7 +71,7 @@ ] -class ResourceReplaceParams(TypedDict, total=False): +class CDNResourceReplaceParams(TypedDict, total=False): origin_group: Required[Annotated[int, PropertyInfo(alias="originGroup")]] """Origin group ID with which the CDN resource is associated. @@ -891,6 +891,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1691,6 +1692,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1922,8 +1926,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/resource_update_params.py b/src/gcore/types/cdn/cdn_resource_update_params.py similarity index 99% rename from src/gcore/types/cdn/resource_update_params.py rename to src/gcore/types/cdn/cdn_resource_update_params.py index c231f15d..9011c2e0 100644 --- a/src/gcore/types/cdn/resource_update_params.py +++ b/src/gcore/types/cdn/cdn_resource_update_params.py @@ -9,7 +9,7 @@ from ..._utils import PropertyInfo __all__ = [ - "ResourceUpdateParams", + "CDNResourceUpdateParams", "Options", "OptionsAllowedHTTPMethods", "OptionsBotProtection", @@ -71,7 +71,7 @@ ] -class ResourceUpdateParams(TypedDict, total=False): +class CDNResourceUpdateParams(TypedDict, total=False): active: bool """Enables or disables a CDN resource. @@ -882,6 +882,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1682,6 +1683,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1913,8 +1917,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/resources/__init__.py b/src/gcore/types/cdn/cdn_resources/__init__.py similarity index 89% rename from src/gcore/types/cdn/resources/__init__.py rename to src/gcore/types/cdn/cdn_resources/__init__.py index f5876a8a..b004f9f1 100644 --- a/src/gcore/types/cdn/resources/__init__.py +++ b/src/gcore/types/cdn/cdn_resources/__init__.py @@ -3,7 +3,7 @@ from __future__ import annotations from .origin_shielding import OriginShielding as OriginShielding -from .cdn_resource_rule import CdnResourceRule as CdnResourceRule +from .cdn_resource_rule import CDNResourceRule as CDNResourceRule from .rule_create_params import RuleCreateParams as RuleCreateParams from .rule_list_response import RuleListResponse as RuleListResponse from .rule_update_params import RuleUpdateParams as RuleUpdateParams diff --git a/src/gcore/types/cdn/resources/cdn_resource_rule.py b/src/gcore/types/cdn/cdn_resources/cdn_resource_rule.py similarity index 99% rename from src/gcore/types/cdn/resources/cdn_resource_rule.py rename to src/gcore/types/cdn/cdn_resources/cdn_resource_rule.py index 2b61a6d2..682384fd 100644 --- a/src/gcore/types/cdn/resources/cdn_resource_rule.py +++ b/src/gcore/types/cdn/cdn_resources/cdn_resource_rule.py @@ -8,7 +8,7 @@ from ...._models import BaseModel __all__ = [ - "CdnResourceRule", + "CDNResourceRule", "Options", "OptionsAllowedHTTPMethods", "OptionsBotProtection", @@ -762,6 +762,7 @@ class OptionsIPAddressACL(BaseModel): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1474,6 +1475,9 @@ class OptionsUserAgentACL(BaseModel): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1699,8 +1703,9 @@ class Options(BaseModel): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1863,7 +1868,7 @@ class Options(BaseModel): """Enables or disables WebSockets connections to an origin server.""" -class CdnResourceRule(BaseModel): +class CDNResourceRule(BaseModel): id: Optional[int] = None """Rule ID.""" diff --git a/src/gcore/types/cdn/resources/origin_shielding.py b/src/gcore/types/cdn/cdn_resources/origin_shielding.py similarity index 100% rename from src/gcore/types/cdn/resources/origin_shielding.py rename to src/gcore/types/cdn/cdn_resources/origin_shielding.py diff --git a/src/gcore/types/cdn/resources/rule_create_params.py b/src/gcore/types/cdn/cdn_resources/rule_create_params.py similarity index 99% rename from src/gcore/types/cdn/resources/rule_create_params.py rename to src/gcore/types/cdn/cdn_resources/rule_create_params.py index 9d48700f..052803bb 100644 --- a/src/gcore/types/cdn/resources/rule_create_params.py +++ b/src/gcore/types/cdn/cdn_resources/rule_create_params.py @@ -838,6 +838,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1548,6 +1549,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1773,8 +1777,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/resources/rule_list_response.py b/src/gcore/types/cdn/cdn_resources/rule_list_response.py similarity index 65% rename from src/gcore/types/cdn/resources/rule_list_response.py rename to src/gcore/types/cdn/cdn_resources/rule_list_response.py index 06cbe617..333d426a 100644 --- a/src/gcore/types/cdn/resources/rule_list_response.py +++ b/src/gcore/types/cdn/cdn_resources/rule_list_response.py @@ -3,8 +3,8 @@ from typing import List from typing_extensions import TypeAlias -from .cdn_resource_rule import CdnResourceRule +from .cdn_resource_rule import CDNResourceRule __all__ = ["RuleListResponse"] -RuleListResponse: TypeAlias = List[CdnResourceRule] +RuleListResponse: TypeAlias = List[CDNResourceRule] diff --git a/src/gcore/types/cdn/resources/rule_replace_params.py b/src/gcore/types/cdn/cdn_resources/rule_replace_params.py similarity index 99% rename from src/gcore/types/cdn/resources/rule_replace_params.py rename to src/gcore/types/cdn/cdn_resources/rule_replace_params.py index 44a3a9f7..86fb2b30 100644 --- a/src/gcore/types/cdn/resources/rule_replace_params.py +++ b/src/gcore/types/cdn/cdn_resources/rule_replace_params.py @@ -840,6 +840,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1550,6 +1551,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1775,8 +1779,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/resources/rule_update_params.py b/src/gcore/types/cdn/cdn_resources/rule_update_params.py similarity index 99% rename from src/gcore/types/cdn/resources/rule_update_params.py rename to src/gcore/types/cdn/cdn_resources/rule_update_params.py index a689c70f..c4ae3b10 100644 --- a/src/gcore/types/cdn/resources/rule_update_params.py +++ b/src/gcore/types/cdn/cdn_resources/rule_update_params.py @@ -840,6 +840,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1550,6 +1551,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1775,8 +1779,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/resources/shield_replace_params.py b/src/gcore/types/cdn/cdn_resources/shield_replace_params.py similarity index 100% rename from src/gcore/types/cdn/resources/shield_replace_params.py rename to src/gcore/types/cdn/cdn_resources/shield_replace_params.py diff --git a/src/gcore/types/cdn/cdn_update_account_params.py b/src/gcore/types/cdn/cdn_update_account_params.py index cfeba9f7..a103687e 100644 --- a/src/gcore/types/cdn/cdn_update_account_params.py +++ b/src/gcore/types/cdn/cdn_update_account_params.py @@ -4,10 +4,10 @@ from typing_extensions import TypedDict -__all__ = ["CdnUpdateAccountParams"] +__all__ = ["CDNUpdateAccountParams"] -class CdnUpdateAccountParams(TypedDict, total=False): +class CDNUpdateAccountParams(TypedDict, total=False): utilization_level: int """CDN traffic usage limit in gigabytes. diff --git a/src/gcore/types/cdn/rule_template.py b/src/gcore/types/cdn/rule_template.py index 12360cca..e23d3805 100644 --- a/src/gcore/types/cdn/rule_template.py +++ b/src/gcore/types/cdn/rule_template.py @@ -762,6 +762,7 @@ class OptionsIPAddressACL(BaseModel): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1474,6 +1475,9 @@ class OptionsUserAgentACL(BaseModel): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1699,8 +1703,9 @@ class Options(BaseModel): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/rule_template_create_params.py b/src/gcore/types/cdn/rule_template_create_params.py index 5a000d28..6d44873b 100644 --- a/src/gcore/types/cdn/rule_template_create_params.py +++ b/src/gcore/types/cdn/rule_template_create_params.py @@ -822,6 +822,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1532,6 +1533,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1757,8 +1761,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/rule_template_replace_params.py b/src/gcore/types/cdn/rule_template_replace_params.py index 4af0182e..7dba15b1 100644 --- a/src/gcore/types/cdn/rule_template_replace_params.py +++ b/src/gcore/types/cdn/rule_template_replace_params.py @@ -822,6 +822,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1532,6 +1533,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1757,8 +1761,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/cdn/rule_template_update_params.py b/src/gcore/types/cdn/rule_template_update_params.py index 8d45b593..37b2ec5b 100644 --- a/src/gcore/types/cdn/rule_template_update_params.py +++ b/src/gcore/types/cdn/rule_template_update_params.py @@ -822,6 +822,7 @@ class OptionsIPAddressACL(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, you have to independently monitor their relevance. + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ @@ -1532,6 +1533,9 @@ class OptionsUserAgentACL(TypedDict, total=False): - **allow** - List of User-Agents for which access is prohibited. - **deny** - List of User-Agents for which access is allowed. + You can provide exact User-Agent strings or regular expressions. Regular + expressions must start with `~` (case-sensitive) or `~*` (case-insensitive). + Use an empty string `""` to allow/deny access when the User-Agent header is empty. """ @@ -1757,8 +1761,9 @@ class Options(TypedDict, total=False): """Controls access to the CDN resource content for specific IP addresses. If you want to use IPs from our CDN servers IP list for IP ACL configuration, - you have to independently monitor their relevance. We recommend you use a script - for automatically update IP ACL. + you have to independently monitor their relevance. + + We recommend you use a script for automatically update IP ACL. [Read more.](/docs/api-reference/cdn/ip-addresses-list/get-cdn-servers-ip-addresses) """ diff --git a/src/gcore/types/iam/account_overview.py b/src/gcore/types/iam/account_overview.py index ab1b57b6..ad8a265e 100644 --- a/src/gcore/types/iam/account_overview.py +++ b/src/gcore/types/iam/account_overview.py @@ -10,21 +10,21 @@ __all__ = [ "AccountOverview", "FreeFeatures", - "FreeFeaturesCdn", + "FreeFeaturesCDN", "FreeFeaturesCloud", "FreeFeaturesDDOS", "FreeFeaturesDNS", "FreeFeaturesStorage", "FreeFeaturesStreaming", "PaidFeatures", - "PaidFeaturesCdn", + "PaidFeaturesCDN", "PaidFeaturesCloud", "PaidFeaturesDDOS", "PaidFeaturesDNS", "PaidFeaturesStorage", "PaidFeaturesStreaming", "ServiceStatuses", - "ServiceStatusesCdn", + "ServiceStatusesCDN", "ServiceStatusesCloud", "ServiceStatusesDDOS", "ServiceStatusesDNS", @@ -35,7 +35,7 @@ ] -class FreeFeaturesCdn(BaseModel): +class FreeFeaturesCDN(BaseModel): """Feature object.""" create_date: Optional[str] = None @@ -154,7 +154,7 @@ class FreeFeatures(BaseModel): An object of arrays which contains information about free features available for the requested account. """ - cdn: Optional[List[FreeFeaturesCdn]] = FieldInfo(alias="CDN", default=None) + cdn: Optional[List[FreeFeaturesCDN]] = FieldInfo(alias="CDN", default=None) cloud: Optional[List[FreeFeaturesCloud]] = FieldInfo(alias="CLOUD", default=None) @@ -167,7 +167,7 @@ class FreeFeatures(BaseModel): streaming: Optional[List[FreeFeaturesStreaming]] = FieldInfo(alias="STREAMING", default=None) -class PaidFeaturesCdn(BaseModel): +class PaidFeaturesCDN(BaseModel): """Feature object.""" create_date: Optional[str] = None @@ -286,7 +286,7 @@ class PaidFeatures(BaseModel): An object of arrays which contains information about paid features available for the requested account. """ - cdn: Optional[List[PaidFeaturesCdn]] = FieldInfo(alias="CDN", default=None) + cdn: Optional[List[PaidFeaturesCDN]] = FieldInfo(alias="CDN", default=None) cloud: Optional[List[PaidFeaturesCloud]] = FieldInfo(alias="CLOUD", default=None) @@ -299,7 +299,7 @@ class PaidFeatures(BaseModel): streaming: Optional[List[PaidFeaturesStreaming]] = FieldInfo(alias="STREAMING", default=None) -class ServiceStatusesCdn(BaseModel): +class ServiceStatusesCDN(BaseModel): enabled: Optional[bool] = None """`true` - service is available in the Control Panel.""" @@ -352,7 +352,7 @@ class ServiceStatuses(BaseModel): An object of arrays which contains information about all services available for the requested account. """ - cdn: Optional[ServiceStatusesCdn] = FieldInfo(alias="CDN", default=None) + cdn: Optional[ServiceStatusesCDN] = FieldInfo(alias="CDN", default=None) cloud: Optional[ServiceStatusesCloud] = FieldInfo(alias="CLOUD", default=None) diff --git a/src/gcore/types/streaming/__init__.py b/src/gcore/types/streaming/__init__.py index 1e0e445a..ab0d0c3c 100644 --- a/src/gcore/types/streaming/__init__.py +++ b/src/gcore/types/streaming/__init__.py @@ -37,7 +37,7 @@ from .create_video_param import CreateVideoParam as CreateVideoParam from .player_list_params import PlayerListParams as PlayerListParams from .stream_list_params import StreamListParams as StreamListParams -from .unique_viewers_cdn import UniqueViewersCdn as UniqueViewersCdn +from .unique_viewers_cdn import UniqueViewersCDN as UniqueViewersCDN from .ai_task_list_params import AITaskListParams as AITaskListParams from .subtitle_base_param import SubtitleBaseParam as SubtitleBaseParam from .video_create_params import VideoCreateParams as VideoCreateParams @@ -102,38 +102,38 @@ StatisticGetMaxStreamsSeriesParams as StatisticGetMaxStreamsSeriesParams, ) from .statistic_get_unique_viewers_cdn_params import ( - StatisticGetUniqueViewersCdnParams as StatisticGetUniqueViewersCdnParams, + StatisticGetUniqueViewersCDNParams as StatisticGetUniqueViewersCDNParams, ) from .statistic_get_vod_storage_volume_params import ( StatisticGetVodStorageVolumeParams as StatisticGetVodStorageVolumeParams, ) from .statistic_get_vod_watch_time_cdn_params import ( - StatisticGetVodWatchTimeCdnParams as StatisticGetVodWatchTimeCdnParams, + StatisticGetVodWatchTimeCDNParams as StatisticGetVodWatchTimeCDNParams, ) from .statistic_get_live_unique_viewers_params import ( StatisticGetLiveUniqueViewersParams as StatisticGetLiveUniqueViewersParams, ) from .statistic_get_live_watch_time_cdn_params import ( - StatisticGetLiveWatchTimeCdnParams as StatisticGetLiveWatchTimeCdnParams, + StatisticGetLiveWatchTimeCDNParams as StatisticGetLiveWatchTimeCDNParams, ) from .statistic_get_live_unique_viewers_response import ( StatisticGetLiveUniqueViewersResponse as StatisticGetLiveUniqueViewersResponse, ) from .statistic_get_vod_unique_viewers_cdn_params import ( - StatisticGetVodUniqueViewersCdnParams as StatisticGetVodUniqueViewersCdnParams, + StatisticGetVodUniqueViewersCDNParams as StatisticGetVodUniqueViewersCDNParams, ) from .statistic_get_vod_transcoding_duration_params import ( StatisticGetVodTranscodingDurationParams as StatisticGetVodTranscodingDurationParams, ) from .statistic_get_vod_watch_time_total_cdn_params import ( - StatisticGetVodWatchTimeTotalCdnParams as StatisticGetVodWatchTimeTotalCdnParams, + StatisticGetVodWatchTimeTotalCDNParams as StatisticGetVodWatchTimeTotalCDNParams, ) from .statistic_get_live_watch_time_total_cdn_params import ( - StatisticGetLiveWatchTimeTotalCdnParams as StatisticGetLiveWatchTimeTotalCdnParams, + StatisticGetLiveWatchTimeTotalCDNParams as StatisticGetLiveWatchTimeTotalCDNParams, ) from .statistic_get_views_by_operating_system_params import ( StatisticGetViewsByOperatingSystemParams as StatisticGetViewsByOperatingSystemParams, ) from .statistic_get_vod_watch_time_total_cdn_response import ( - StatisticGetVodWatchTimeTotalCdnResponse as StatisticGetVodWatchTimeTotalCdnResponse, + StatisticGetVodWatchTimeTotalCDNResponse as StatisticGetVodWatchTimeTotalCDNResponse, ) diff --git a/src/gcore/types/streaming/playlist.py b/src/gcore/types/streaming/playlist.py index 495c206d..e0f94e66 100644 --- a/src/gcore/types/streaming/playlist.py +++ b/src/gcore/types/streaming/playlist.py @@ -49,6 +49,7 @@ class Playlist(BaseModel): This URL is a link to the main manifest. But you can also manually specify suffix-options that will allow you to change the manifest to your request: + `/playlists/{client_id}_{playlist_id}/master[-cmaf][-min-N][-max-N][-img][-(h264|hevc|av1)].m3u8` Please see the details in `hls_url` attribute of /videos/{id} method. diff --git a/src/gcore/types/streaming/playlist_create_params.py b/src/gcore/types/streaming/playlist_create_params.py index f9102a3f..2eebe230 100644 --- a/src/gcore/types/streaming/playlist_create_params.py +++ b/src/gcore/types/streaming/playlist_create_params.py @@ -49,6 +49,7 @@ class PlaylistCreateParams(TypedDict, total=False): This URL is a link to the main manifest. But you can also manually specify suffix-options that will allow you to change the manifest to your request: + `/playlists/{client_id}_{playlist_id}/master[-cmaf][-min-N][-max-N][-img][-(h264|hevc|av1)].m3u8` Please see the details in `hls_url` attribute of /videos/{id} method. diff --git a/src/gcore/types/streaming/playlist_update_params.py b/src/gcore/types/streaming/playlist_update_params.py index 10fe4362..ce411690 100644 --- a/src/gcore/types/streaming/playlist_update_params.py +++ b/src/gcore/types/streaming/playlist_update_params.py @@ -49,6 +49,7 @@ class PlaylistUpdateParams(TypedDict, total=False): This URL is a link to the main manifest. But you can also manually specify suffix-options that will allow you to change the manifest to your request: + `/playlists/{client_id}_{playlist_id}/master[-cmaf][-min-N][-max-N][-img][-(h264|hevc|av1)].m3u8` Please see the details in `hls_url` attribute of /videos/{id} method. diff --git a/src/gcore/types/streaming/statistic_get_live_watch_time_cdn_params.py b/src/gcore/types/streaming/statistic_get_live_watch_time_cdn_params.py index 74e37c52..a1b6a767 100644 --- a/src/gcore/types/streaming/statistic_get_live_watch_time_cdn_params.py +++ b/src/gcore/types/streaming/statistic_get_live_watch_time_cdn_params.py @@ -6,10 +6,10 @@ from ..._utils import PropertyInfo -__all__ = ["StatisticGetLiveWatchTimeCdnParams"] +__all__ = ["StatisticGetLiveWatchTimeCDNParams"] -class StatisticGetLiveWatchTimeCdnParams(TypedDict, total=False): +class StatisticGetLiveWatchTimeCDNParams(TypedDict, total=False): from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start of the time period for counting minutes of watching. diff --git a/src/gcore/types/streaming/statistic_get_live_watch_time_total_cdn_params.py b/src/gcore/types/streaming/statistic_get_live_watch_time_total_cdn_params.py index 0711a555..1eedab5e 100644 --- a/src/gcore/types/streaming/statistic_get_live_watch_time_total_cdn_params.py +++ b/src/gcore/types/streaming/statistic_get_live_watch_time_total_cdn_params.py @@ -6,10 +6,10 @@ from ..._utils import PropertyInfo -__all__ = ["StatisticGetLiveWatchTimeTotalCdnParams"] +__all__ = ["StatisticGetLiveWatchTimeTotalCDNParams"] -class StatisticGetLiveWatchTimeTotalCdnParams(TypedDict, total=False): +class StatisticGetLiveWatchTimeTotalCDNParams(TypedDict, total=False): client_user_id: int """Filter by field "client_user_id" """ diff --git a/src/gcore/types/streaming/statistic_get_unique_viewers_cdn_params.py b/src/gcore/types/streaming/statistic_get_unique_viewers_cdn_params.py index b8da4126..4944d6da 100644 --- a/src/gcore/types/streaming/statistic_get_unique_viewers_cdn_params.py +++ b/src/gcore/types/streaming/statistic_get_unique_viewers_cdn_params.py @@ -4,10 +4,10 @@ from typing_extensions import Literal, Required, TypedDict -__all__ = ["StatisticGetUniqueViewersCdnParams"] +__all__ = ["StatisticGetUniqueViewersCDNParams"] -class StatisticGetUniqueViewersCdnParams(TypedDict, total=False): +class StatisticGetUniqueViewersCDNParams(TypedDict, total=False): date_from: Required[str] """Start of time frame. Format is date time in ISO 8601.""" diff --git a/src/gcore/types/streaming/statistic_get_vod_unique_viewers_cdn_params.py b/src/gcore/types/streaming/statistic_get_vod_unique_viewers_cdn_params.py index a0ed38cb..8ad50cc1 100644 --- a/src/gcore/types/streaming/statistic_get_vod_unique_viewers_cdn_params.py +++ b/src/gcore/types/streaming/statistic_get_vod_unique_viewers_cdn_params.py @@ -6,10 +6,10 @@ from ..._utils import PropertyInfo -__all__ = ["StatisticGetVodUniqueViewersCdnParams"] +__all__ = ["StatisticGetVodUniqueViewersCDNParams"] -class StatisticGetVodUniqueViewersCdnParams(TypedDict, total=False): +class StatisticGetVodUniqueViewersCDNParams(TypedDict, total=False): from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start of time frame. Format is date time in ISO 8601""" diff --git a/src/gcore/types/streaming/statistic_get_vod_watch_time_cdn_params.py b/src/gcore/types/streaming/statistic_get_vod_watch_time_cdn_params.py index f7af2996..7fde051e 100644 --- a/src/gcore/types/streaming/statistic_get_vod_watch_time_cdn_params.py +++ b/src/gcore/types/streaming/statistic_get_vod_watch_time_cdn_params.py @@ -6,10 +6,10 @@ from ..._utils import PropertyInfo -__all__ = ["StatisticGetVodWatchTimeCdnParams"] +__all__ = ["StatisticGetVodWatchTimeCDNParams"] -class StatisticGetVodWatchTimeCdnParams(TypedDict, total=False): +class StatisticGetVodWatchTimeCDNParams(TypedDict, total=False): from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start of the time period for counting minutes of watching. diff --git a/src/gcore/types/streaming/statistic_get_vod_watch_time_total_cdn_params.py b/src/gcore/types/streaming/statistic_get_vod_watch_time_total_cdn_params.py index 2599d8bd..009ea82e 100644 --- a/src/gcore/types/streaming/statistic_get_vod_watch_time_total_cdn_params.py +++ b/src/gcore/types/streaming/statistic_get_vod_watch_time_total_cdn_params.py @@ -6,10 +6,10 @@ from ..._utils import PropertyInfo -__all__ = ["StatisticGetVodWatchTimeTotalCdnParams"] +__all__ = ["StatisticGetVodWatchTimeTotalCDNParams"] -class StatisticGetVodWatchTimeTotalCdnParams(TypedDict, total=False): +class StatisticGetVodWatchTimeTotalCDNParams(TypedDict, total=False): client_user_id: int """Filter by field "client_user_id" """ diff --git a/src/gcore/types/streaming/statistic_get_vod_watch_time_total_cdn_response.py b/src/gcore/types/streaming/statistic_get_vod_watch_time_total_cdn_response.py index 6e5e61c6..026684ad 100644 --- a/src/gcore/types/streaming/statistic_get_vod_watch_time_total_cdn_response.py +++ b/src/gcore/types/streaming/statistic_get_vod_watch_time_total_cdn_response.py @@ -5,10 +5,10 @@ from ..._models import BaseModel -__all__ = ["StatisticGetVodWatchTimeTotalCdnResponse", "StatisticGetVodWatchTimeTotalCdnResponseItem"] +__all__ = ["StatisticGetVodWatchTimeTotalCDNResponse", "StatisticGetVodWatchTimeTotalCDNResponseItem"] -class StatisticGetVodWatchTimeTotalCdnResponseItem(BaseModel): +class StatisticGetVodWatchTimeTotalCDNResponseItem(BaseModel): client: int duration: int @@ -19,4 +19,4 @@ class StatisticGetVodWatchTimeTotalCdnResponseItem(BaseModel): slug: Optional[str] = None -StatisticGetVodWatchTimeTotalCdnResponse: TypeAlias = List[StatisticGetVodWatchTimeTotalCdnResponseItem] +StatisticGetVodWatchTimeTotalCDNResponse: TypeAlias = List[StatisticGetVodWatchTimeTotalCDNResponseItem] diff --git a/src/gcore/types/streaming/unique_viewers_cdn.py b/src/gcore/types/streaming/unique_viewers_cdn.py index a7afa0fe..ab3f1f1e 100644 --- a/src/gcore/types/streaming/unique_viewers_cdn.py +++ b/src/gcore/types/streaming/unique_viewers_cdn.py @@ -4,7 +4,7 @@ from ..._models import BaseModel -__all__ = ["UniqueViewersCdn", "Data"] +__all__ = ["UniqueViewersCDN", "Data"] class Data(BaseModel): @@ -13,5 +13,5 @@ class Data(BaseModel): uniqs: int -class UniqueViewersCdn(BaseModel): +class UniqueViewersCDN(BaseModel): data: Optional[List[Data]] = None diff --git a/src/gcore/types/streaming/video.py b/src/gcore/types/streaming/video.py index c12c6453..f6a405ee 100644 --- a/src/gcore/types/streaming/video.py +++ b/src/gcore/types/streaming/video.py @@ -85,7 +85,9 @@ class ConvertedVideo(BaseModel): **Default MP4 file name structure** Link to the file {filename} contains information about the encoding method using - format: `___.mp4` + format: + + `___.mp4` - `` – Internal quality identifier and file version. Please do not use it, can be changed at any time without any notice. diff --git a/src/gcore/types/waap/domains/statistic_get_events_aggregated_params.py b/src/gcore/types/waap/domains/statistic_get_events_aggregated_params.py index ff19e38c..4cfc9bcd 100644 --- a/src/gcore/types/waap/domains/statistic_get_events_aggregated_params.py +++ b/src/gcore/types/waap/domains/statistic_get_events_aggregated_params.py @@ -14,7 +14,7 @@ class StatisticGetEventsAggregatedParams(TypedDict, total=False): start: Required[str] """Filter data items starting from a specified date in ISO 8601 format""" - action: Optional[List[Literal["block", "captcha", "handshake", "monitor"]]] + action: Optional[List[Literal["allow", "block", "captcha", "handshake"]]] """A list of action names to filter on.""" end: Optional[str] diff --git a/tests/api_resources/cdn/resources/__init__.py b/tests/api_resources/cdn/cdn_resources/__init__.py similarity index 100% rename from tests/api_resources/cdn/resources/__init__.py rename to tests/api_resources/cdn/cdn_resources/__init__.py diff --git a/tests/api_resources/cdn/resources/test_rules.py b/tests/api_resources/cdn/cdn_resources/test_rules.py similarity index 92% rename from tests/api_resources/cdn/resources/test_rules.py rename to tests/api_resources/cdn/cdn_resources/test_rules.py index 63940c96..5fd9a3d7 100644 --- a/tests/api_resources/cdn/resources/test_rules.py +++ b/tests/api_resources/cdn/cdn_resources/test_rules.py @@ -9,8 +9,8 @@ from gcore import Gcore, AsyncGcore from tests.utils import assert_matches_type -from gcore.types.cdn.resources import ( - CdnResourceRule, +from gcore.types.cdn.cdn_resources import ( + CDNResourceRule, RuleListResponse, ) @@ -22,17 +22,17 @@ class TestRules: @parametrize def test_method_create(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.create( + rule = client.cdn.cdn_resources.rules.create( resource_id=0, name="My first rule", rule="/folder/images/*.png", rule_type=0, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.create( + rule = client.cdn.cdn_resources.rules.create( resource_id=0, name="My first rule", rule="/folder/images/*.png", @@ -291,7 +291,7 @@ def test_method_create_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -307,11 +307,11 @@ def test_method_create_with_all_params(self, client: Gcore) -> None: override_origin_protocol="HTTPS", weight=1, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_raw_response_create(self, client: Gcore) -> None: - response = client.cdn.resources.rules.with_raw_response.create( + response = client.cdn.cdn_resources.rules.with_raw_response.create( resource_id=0, name="My first rule", rule="/folder/images/*.png", @@ -321,11 +321,11 @@ def test_raw_response_create(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_streaming_response_create(self, client: Gcore) -> None: - with client.cdn.resources.rules.with_streaming_response.create( + with client.cdn.cdn_resources.rules.with_streaming_response.create( resource_id=0, name="My first rule", rule="/folder/images/*.png", @@ -335,21 +335,21 @@ def test_streaming_response_create(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_update(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.update( + rule = client.cdn.cdn_resources.rules.update( rule_id=0, resource_id=0, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.update( + rule = client.cdn.cdn_resources.rules.update( rule_id=0, resource_id=0, active=True, @@ -607,7 +607,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -625,11 +625,11 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: rule_type=0, weight=1, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_raw_response_update(self, client: Gcore) -> None: - response = client.cdn.resources.rules.with_raw_response.update( + response = client.cdn.cdn_resources.rules.with_raw_response.update( rule_id=0, resource_id=0, ) @@ -637,11 +637,11 @@ def test_raw_response_update(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_streaming_response_update(self, client: Gcore) -> None: - with client.cdn.resources.rules.with_streaming_response.update( + with client.cdn.cdn_resources.rules.with_streaming_response.update( rule_id=0, resource_id=0, ) as response: @@ -649,20 +649,20 @@ def test_streaming_response_update(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_list(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.list( + rule = client.cdn.cdn_resources.rules.list( 0, ) assert_matches_type(RuleListResponse, rule, path=["response"]) @parametrize def test_raw_response_list(self, client: Gcore) -> None: - response = client.cdn.resources.rules.with_raw_response.list( + response = client.cdn.cdn_resources.rules.with_raw_response.list( 0, ) @@ -673,7 +673,7 @@ def test_raw_response_list(self, client: Gcore) -> None: @parametrize def test_streaming_response_list(self, client: Gcore) -> None: - with client.cdn.resources.rules.with_streaming_response.list( + with client.cdn.cdn_resources.rules.with_streaming_response.list( 0, ) as response: assert not response.is_closed @@ -686,7 +686,7 @@ def test_streaming_response_list(self, client: Gcore) -> None: @parametrize def test_method_delete(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.delete( + rule = client.cdn.cdn_resources.rules.delete( rule_id=0, resource_id=0, ) @@ -694,7 +694,7 @@ def test_method_delete(self, client: Gcore) -> None: @parametrize def test_raw_response_delete(self, client: Gcore) -> None: - response = client.cdn.resources.rules.with_raw_response.delete( + response = client.cdn.cdn_resources.rules.with_raw_response.delete( rule_id=0, resource_id=0, ) @@ -706,7 +706,7 @@ def test_raw_response_delete(self, client: Gcore) -> None: @parametrize def test_streaming_response_delete(self, client: Gcore) -> None: - with client.cdn.resources.rules.with_streaming_response.delete( + with client.cdn.cdn_resources.rules.with_streaming_response.delete( rule_id=0, resource_id=0, ) as response: @@ -720,15 +720,15 @@ def test_streaming_response_delete(self, client: Gcore) -> None: @parametrize def test_method_get(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.get( + rule = client.cdn.cdn_resources.rules.get( rule_id=0, resource_id=0, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_raw_response_get(self, client: Gcore) -> None: - response = client.cdn.resources.rules.with_raw_response.get( + response = client.cdn.cdn_resources.rules.with_raw_response.get( rule_id=0, resource_id=0, ) @@ -736,11 +736,11 @@ def test_raw_response_get(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_streaming_response_get(self, client: Gcore) -> None: - with client.cdn.resources.rules.with_streaming_response.get( + with client.cdn.cdn_resources.rules.with_streaming_response.get( rule_id=0, resource_id=0, ) as response: @@ -748,23 +748,23 @@ def test_streaming_response_get(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_replace(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.replace( + rule = client.cdn.cdn_resources.rules.replace( rule_id=0, resource_id=0, rule="/folder/images/*.png", rule_type=0, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_method_replace_with_all_params(self, client: Gcore) -> None: - rule = client.cdn.resources.rules.replace( + rule = client.cdn.cdn_resources.rules.replace( rule_id=0, resource_id=0, rule="/folder/images/*.png", @@ -1024,7 +1024,7 @@ def test_method_replace_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -1040,11 +1040,11 @@ def test_method_replace_with_all_params(self, client: Gcore) -> None: override_origin_protocol="HTTPS", weight=1, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_raw_response_replace(self, client: Gcore) -> None: - response = client.cdn.resources.rules.with_raw_response.replace( + response = client.cdn.cdn_resources.rules.with_raw_response.replace( rule_id=0, resource_id=0, rule="/folder/images/*.png", @@ -1054,11 +1054,11 @@ def test_raw_response_replace(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize def test_streaming_response_replace(self, client: Gcore) -> None: - with client.cdn.resources.rules.with_streaming_response.replace( + with client.cdn.cdn_resources.rules.with_streaming_response.replace( rule_id=0, resource_id=0, rule="/folder/images/*.png", @@ -1068,7 +1068,7 @@ def test_streaming_response_replace(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1080,17 +1080,17 @@ class TestAsyncRules: @parametrize async def test_method_create(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.create( + rule = await async_client.cdn.cdn_resources.rules.create( resource_id=0, name="My first rule", rule="/folder/images/*.png", rule_type=0, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.create( + rule = await async_client.cdn.cdn_resources.rules.create( resource_id=0, name="My first rule", rule="/folder/images/*.png", @@ -1349,7 +1349,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -1365,11 +1365,11 @@ async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> override_origin_protocol="HTTPS", weight=1, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.rules.with_raw_response.create( + response = await async_client.cdn.cdn_resources.rules.with_raw_response.create( resource_id=0, name="My first rule", rule="/folder/images/*.png", @@ -1379,11 +1379,11 @@ async def test_raw_response_create(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.rules.with_streaming_response.create( + async with async_client.cdn.cdn_resources.rules.with_streaming_response.create( resource_id=0, name="My first rule", rule="/folder/images/*.png", @@ -1393,21 +1393,21 @@ async def test_streaming_response_create(self, async_client: AsyncGcore) -> None assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_update(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.update( + rule = await async_client.cdn.cdn_resources.rules.update( rule_id=0, resource_id=0, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.update( + rule = await async_client.cdn.cdn_resources.rules.update( rule_id=0, resource_id=0, active=True, @@ -1665,7 +1665,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -1683,11 +1683,11 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> rule_type=0, weight=1, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.rules.with_raw_response.update( + response = await async_client.cdn.cdn_resources.rules.with_raw_response.update( rule_id=0, resource_id=0, ) @@ -1695,11 +1695,11 @@ async def test_raw_response_update(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.rules.with_streaming_response.update( + async with async_client.cdn.cdn_resources.rules.with_streaming_response.update( rule_id=0, resource_id=0, ) as response: @@ -1707,20 +1707,20 @@ async def test_streaming_response_update(self, async_client: AsyncGcore) -> None assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_list(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.list( + rule = await async_client.cdn.cdn_resources.rules.list( 0, ) assert_matches_type(RuleListResponse, rule, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.rules.with_raw_response.list( + response = await async_client.cdn.cdn_resources.rules.with_raw_response.list( 0, ) @@ -1731,7 +1731,7 @@ async def test_raw_response_list(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.rules.with_streaming_response.list( + async with async_client.cdn.cdn_resources.rules.with_streaming_response.list( 0, ) as response: assert not response.is_closed @@ -1744,7 +1744,7 @@ async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: @parametrize async def test_method_delete(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.delete( + rule = await async_client.cdn.cdn_resources.rules.delete( rule_id=0, resource_id=0, ) @@ -1752,7 +1752,7 @@ async def test_method_delete(self, async_client: AsyncGcore) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.rules.with_raw_response.delete( + response = await async_client.cdn.cdn_resources.rules.with_raw_response.delete( rule_id=0, resource_id=0, ) @@ -1764,7 +1764,7 @@ async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.rules.with_streaming_response.delete( + async with async_client.cdn.cdn_resources.rules.with_streaming_response.delete( rule_id=0, resource_id=0, ) as response: @@ -1778,15 +1778,15 @@ async def test_streaming_response_delete(self, async_client: AsyncGcore) -> None @parametrize async def test_method_get(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.get( + rule = await async_client.cdn.cdn_resources.rules.get( rule_id=0, resource_id=0, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.rules.with_raw_response.get( + response = await async_client.cdn.cdn_resources.rules.with_raw_response.get( rule_id=0, resource_id=0, ) @@ -1794,11 +1794,11 @@ async def test_raw_response_get(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.rules.with_streaming_response.get( + async with async_client.cdn.cdn_resources.rules.with_streaming_response.get( rule_id=0, resource_id=0, ) as response: @@ -1806,23 +1806,23 @@ async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_replace(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.replace( + rule = await async_client.cdn.cdn_resources.rules.replace( rule_id=0, resource_id=0, rule="/folder/images/*.png", rule_type=0, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> None: - rule = await async_client.cdn.resources.rules.replace( + rule = await async_client.cdn.cdn_resources.rules.replace( rule_id=0, resource_id=0, rule="/folder/images/*.png", @@ -2082,7 +2082,7 @@ async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -2098,11 +2098,11 @@ async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> override_origin_protocol="HTTPS", weight=1, ) - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_raw_response_replace(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.rules.with_raw_response.replace( + response = await async_client.cdn.cdn_resources.rules.with_raw_response.replace( rule_id=0, resource_id=0, rule="/folder/images/*.png", @@ -2112,11 +2112,11 @@ async def test_raw_response_replace(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) @parametrize async def test_streaming_response_replace(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.rules.with_streaming_response.replace( + async with async_client.cdn.cdn_resources.rules.with_streaming_response.replace( rule_id=0, resource_id=0, rule="/folder/images/*.png", @@ -2126,6 +2126,6 @@ async def test_streaming_response_replace(self, async_client: AsyncGcore) -> Non assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(CdnResourceRule, rule, path=["response"]) + assert_matches_type(CDNResourceRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cdn/resources/test_shield.py b/tests/api_resources/cdn/cdn_resources/test_shield.py similarity index 82% rename from tests/api_resources/cdn/resources/test_shield.py rename to tests/api_resources/cdn/cdn_resources/test_shield.py index 40679e62..dcc9f67c 100644 --- a/tests/api_resources/cdn/resources/test_shield.py +++ b/tests/api_resources/cdn/cdn_resources/test_shield.py @@ -9,7 +9,7 @@ from gcore import Gcore, AsyncGcore from tests.utils import assert_matches_type -from gcore.types.cdn.resources import OriginShielding +from gcore.types.cdn.cdn_resources import OriginShielding base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -19,14 +19,14 @@ class TestShield: @parametrize def test_method_get(self, client: Gcore) -> None: - shield = client.cdn.resources.shield.get( + shield = client.cdn.cdn_resources.shield.get( 0, ) assert_matches_type(OriginShielding, shield, path=["response"]) @parametrize def test_raw_response_get(self, client: Gcore) -> None: - response = client.cdn.resources.shield.with_raw_response.get( + response = client.cdn.cdn_resources.shield.with_raw_response.get( 0, ) @@ -37,7 +37,7 @@ def test_raw_response_get(self, client: Gcore) -> None: @parametrize def test_streaming_response_get(self, client: Gcore) -> None: - with client.cdn.resources.shield.with_streaming_response.get( + with client.cdn.cdn_resources.shield.with_streaming_response.get( 0, ) as response: assert not response.is_closed @@ -50,14 +50,14 @@ def test_streaming_response_get(self, client: Gcore) -> None: @parametrize def test_method_replace(self, client: Gcore) -> None: - shield = client.cdn.resources.shield.replace( + shield = client.cdn.cdn_resources.shield.replace( resource_id=0, ) assert_matches_type(object, shield, path=["response"]) @parametrize def test_method_replace_with_all_params(self, client: Gcore) -> None: - shield = client.cdn.resources.shield.replace( + shield = client.cdn.cdn_resources.shield.replace( resource_id=0, shielding_pop=4, ) @@ -65,7 +65,7 @@ def test_method_replace_with_all_params(self, client: Gcore) -> None: @parametrize def test_raw_response_replace(self, client: Gcore) -> None: - response = client.cdn.resources.shield.with_raw_response.replace( + response = client.cdn.cdn_resources.shield.with_raw_response.replace( resource_id=0, ) @@ -76,7 +76,7 @@ def test_raw_response_replace(self, client: Gcore) -> None: @parametrize def test_streaming_response_replace(self, client: Gcore) -> None: - with client.cdn.resources.shield.with_streaming_response.replace( + with client.cdn.cdn_resources.shield.with_streaming_response.replace( resource_id=0, ) as response: assert not response.is_closed @@ -95,14 +95,14 @@ class TestAsyncShield: @parametrize async def test_method_get(self, async_client: AsyncGcore) -> None: - shield = await async_client.cdn.resources.shield.get( + shield = await async_client.cdn.cdn_resources.shield.get( 0, ) assert_matches_type(OriginShielding, shield, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.shield.with_raw_response.get( + response = await async_client.cdn.cdn_resources.shield.with_raw_response.get( 0, ) @@ -113,7 +113,7 @@ async def test_raw_response_get(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.shield.with_streaming_response.get( + async with async_client.cdn.cdn_resources.shield.with_streaming_response.get( 0, ) as response: assert not response.is_closed @@ -126,14 +126,14 @@ async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: @parametrize async def test_method_replace(self, async_client: AsyncGcore) -> None: - shield = await async_client.cdn.resources.shield.replace( + shield = await async_client.cdn.cdn_resources.shield.replace( resource_id=0, ) assert_matches_type(object, shield, path=["response"]) @parametrize async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> None: - shield = await async_client.cdn.resources.shield.replace( + shield = await async_client.cdn.cdn_resources.shield.replace( resource_id=0, shielding_pop=4, ) @@ -141,7 +141,7 @@ async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> @parametrize async def test_raw_response_replace(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.shield.with_raw_response.replace( + response = await async_client.cdn.cdn_resources.shield.with_raw_response.replace( resource_id=0, ) @@ -152,7 +152,7 @@ async def test_raw_response_replace(self, async_client: AsyncGcore) -> None: @parametrize async def test_streaming_response_replace(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.shield.with_streaming_response.replace( + async with async_client.cdn.cdn_resources.shield.with_streaming_response.replace( resource_id=0, ) as response: assert not response.is_closed diff --git a/tests/api_resources/cdn/test_audit_logs.py b/tests/api_resources/cdn/test_audit_logs.py index 3aace823..ae9cea06 100644 --- a/tests/api_resources/cdn/test_audit_logs.py +++ b/tests/api_resources/cdn/test_audit_logs.py @@ -9,7 +9,7 @@ from gcore import Gcore, AsyncGcore from tests.utils import assert_matches_type -from gcore.types.cdn import CdnAuditLogEntry +from gcore.types.cdn import CDNAuditLogEntry from gcore.pagination import SyncOffsetPage, AsyncOffsetPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -21,7 +21,7 @@ class TestAuditLogs: @parametrize def test_method_list(self, client: Gcore) -> None: audit_log = client.cdn.audit_logs.list() - assert_matches_type(SyncOffsetPage[CdnAuditLogEntry], audit_log, path=["response"]) + assert_matches_type(SyncOffsetPage[CDNAuditLogEntry], audit_log, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Gcore) -> None: @@ -38,7 +38,7 @@ def test_method_list_with_all_params(self, client: Gcore) -> None: token_id=0, user_id=0, ) - assert_matches_type(SyncOffsetPage[CdnAuditLogEntry], audit_log, path=["response"]) + assert_matches_type(SyncOffsetPage[CDNAuditLogEntry], audit_log, path=["response"]) @parametrize def test_raw_response_list(self, client: Gcore) -> None: @@ -47,7 +47,7 @@ def test_raw_response_list(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" audit_log = response.parse() - assert_matches_type(SyncOffsetPage[CdnAuditLogEntry], audit_log, path=["response"]) + assert_matches_type(SyncOffsetPage[CDNAuditLogEntry], audit_log, path=["response"]) @parametrize def test_streaming_response_list(self, client: Gcore) -> None: @@ -56,7 +56,7 @@ def test_streaming_response_list(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" audit_log = response.parse() - assert_matches_type(SyncOffsetPage[CdnAuditLogEntry], audit_log, path=["response"]) + assert_matches_type(SyncOffsetPage[CDNAuditLogEntry], audit_log, path=["response"]) assert cast(Any, response.is_closed) is True @@ -65,7 +65,7 @@ def test_method_get(self, client: Gcore) -> None: audit_log = client.cdn.audit_logs.get( 0, ) - assert_matches_type(CdnAuditLogEntry, audit_log, path=["response"]) + assert_matches_type(CDNAuditLogEntry, audit_log, path=["response"]) @parametrize def test_raw_response_get(self, client: Gcore) -> None: @@ -76,7 +76,7 @@ def test_raw_response_get(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" audit_log = response.parse() - assert_matches_type(CdnAuditLogEntry, audit_log, path=["response"]) + assert_matches_type(CDNAuditLogEntry, audit_log, path=["response"]) @parametrize def test_streaming_response_get(self, client: Gcore) -> None: @@ -87,7 +87,7 @@ def test_streaming_response_get(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" audit_log = response.parse() - assert_matches_type(CdnAuditLogEntry, audit_log, path=["response"]) + assert_matches_type(CDNAuditLogEntry, audit_log, path=["response"]) assert cast(Any, response.is_closed) is True @@ -100,7 +100,7 @@ class TestAsyncAuditLogs: @parametrize async def test_method_list(self, async_client: AsyncGcore) -> None: audit_log = await async_client.cdn.audit_logs.list() - assert_matches_type(AsyncOffsetPage[CdnAuditLogEntry], audit_log, path=["response"]) + assert_matches_type(AsyncOffsetPage[CDNAuditLogEntry], audit_log, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> None: @@ -117,7 +117,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> No token_id=0, user_id=0, ) - assert_matches_type(AsyncOffsetPage[CdnAuditLogEntry], audit_log, path=["response"]) + assert_matches_type(AsyncOffsetPage[CDNAuditLogEntry], audit_log, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncGcore) -> None: @@ -126,7 +126,7 @@ async def test_raw_response_list(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" audit_log = await response.parse() - assert_matches_type(AsyncOffsetPage[CdnAuditLogEntry], audit_log, path=["response"]) + assert_matches_type(AsyncOffsetPage[CDNAuditLogEntry], audit_log, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: @@ -135,7 +135,7 @@ async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" audit_log = await response.parse() - assert_matches_type(AsyncOffsetPage[CdnAuditLogEntry], audit_log, path=["response"]) + assert_matches_type(AsyncOffsetPage[CDNAuditLogEntry], audit_log, path=["response"]) assert cast(Any, response.is_closed) is True @@ -144,7 +144,7 @@ async def test_method_get(self, async_client: AsyncGcore) -> None: audit_log = await async_client.cdn.audit_logs.get( 0, ) - assert_matches_type(CdnAuditLogEntry, audit_log, path=["response"]) + assert_matches_type(CDNAuditLogEntry, audit_log, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncGcore) -> None: @@ -155,7 +155,7 @@ async def test_raw_response_get(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" audit_log = await response.parse() - assert_matches_type(CdnAuditLogEntry, audit_log, path=["response"]) + assert_matches_type(CDNAuditLogEntry, audit_log, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: @@ -166,6 +166,6 @@ async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" audit_log = await response.parse() - assert_matches_type(CdnAuditLogEntry, audit_log, path=["response"]) + assert_matches_type(CDNAuditLogEntry, audit_log, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cdn/test_resources.py b/tests/api_resources/cdn/test_cdn_resources.py similarity index 87% rename from tests/api_resources/cdn/test_resources.py rename to tests/api_resources/cdn/test_cdn_resources.py index debacd03..79f8e5db 100644 --- a/tests/api_resources/cdn/test_resources.py +++ b/tests/api_resources/cdn/test_cdn_resources.py @@ -10,28 +10,28 @@ from gcore import Gcore, AsyncGcore from tests.utils import assert_matches_type from gcore.types.cdn import ( - CdnResource, - CdnResourceList, + CDNResource, + CDNResourceList, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -class TestResources: +class TestCDNResources: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize def test_method_create(self, client: Gcore) -> None: - resource = client.cdn.resources.create( + cdn_resource = client.cdn.cdn_resources.create( cname="cdn.site.com", origin="example.com", origin_group=132, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Gcore) -> None: - resource = client.cdn.resources.create( + cdn_resource = client.cdn.cdn_resources.create( cname="cdn.site.com", origin="example.com", origin_group=132, @@ -311,7 +311,7 @@ def test_method_create_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -333,11 +333,11 @@ def test_method_create_with_all_params(self, client: Gcore) -> None: ssl_enabled=False, waap_api_domain_enabled=True, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize def test_raw_response_create(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.create( + response = client.cdn.cdn_resources.with_raw_response.create( cname="cdn.site.com", origin="example.com", origin_group=132, @@ -345,12 +345,12 @@ def test_raw_response_create(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize def test_streaming_response_create(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.create( + with client.cdn.cdn_resources.with_streaming_response.create( cname="cdn.site.com", origin="example.com", origin_group=132, @@ -358,23 +358,23 @@ def test_streaming_response_create(self, client: Gcore) -> None: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="unexpected prism python test failures") @parametrize def test_method_update(self, client: Gcore) -> None: - resource = client.cdn.resources.update( + cdn_resource = client.cdn.cdn_resources.update( resource_id=0, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @pytest.mark.skip(reason="unexpected prism python test failures") @parametrize def test_method_update_with_all_params(self, client: Gcore) -> None: - resource = client.cdn.resources.update( + cdn_resource = client.cdn.cdn_resources.update( resource_id=0, active=True, description="My resource", @@ -652,7 +652,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -673,42 +673,42 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: ssl_data=192, ssl_enabled=False, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @pytest.mark.skip(reason="unexpected prism python test failures") @parametrize def test_raw_response_update(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.update( + response = client.cdn.cdn_resources.with_raw_response.update( resource_id=0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @pytest.mark.skip(reason="unexpected prism python test failures") @parametrize def test_streaming_response_update(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.update( + with client.cdn.cdn_resources.with_streaming_response.update( resource_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_list(self, client: Gcore) -> None: - resource = client.cdn.resources.list() - assert_matches_type(CdnResourceList, resource, path=["response"]) + cdn_resource = client.cdn.cdn_resources.list() + assert_matches_type(CDNResourceList, cdn_resource, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Gcore) -> None: - resource = client.cdn.resources.list( + cdn_resource = client.cdn.cdn_resources.list( cname="cname", deleted=True, enabled=True, @@ -726,283 +726,283 @@ def test_method_list_with_all_params(self, client: Gcore) -> None: suspend=True, vp_enabled=True, ) - assert_matches_type(CdnResourceList, resource, path=["response"]) + assert_matches_type(CDNResourceList, cdn_resource, path=["response"]) @parametrize def test_raw_response_list(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.list() + response = client.cdn.cdn_resources.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResourceList, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResourceList, cdn_resource, path=["response"]) @parametrize def test_streaming_response_list(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.list() as response: + with client.cdn.cdn_resources.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResourceList, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResourceList, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_delete(self, client: Gcore) -> None: - resource = client.cdn.resources.delete( + cdn_resource = client.cdn.cdn_resources.delete( 0, ) - assert resource is None + assert cdn_resource is None @parametrize def test_raw_response_delete(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.delete( + response = client.cdn.cdn_resources.with_raw_response.delete( 0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None @parametrize def test_streaming_response_delete(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.delete( + with client.cdn.cdn_resources.with_streaming_response.delete( 0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize def test_method_get(self, client: Gcore) -> None: - resource = client.cdn.resources.get( + cdn_resource = client.cdn.cdn_resources.get( 0, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize def test_raw_response_get(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.get( + response = client.cdn.cdn_resources.with_raw_response.get( 0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize def test_streaming_response_get(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.get( + with client.cdn.cdn_resources.with_streaming_response.get( 0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_prefetch(self, client: Gcore) -> None: - resource = client.cdn.resources.prefetch( + cdn_resource = client.cdn.cdn_resources.prefetch( resource_id=0, paths=["/test.jpg", "test1.jpg"], ) - assert resource is None + assert cdn_resource is None @parametrize def test_raw_response_prefetch(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.prefetch( + response = client.cdn.cdn_resources.with_raw_response.prefetch( resource_id=0, paths=["/test.jpg", "test1.jpg"], ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None @parametrize def test_streaming_response_prefetch(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.prefetch( + with client.cdn.cdn_resources.with_streaming_response.prefetch( resource_id=0, paths=["/test.jpg", "test1.jpg"], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize def test_method_prevalidate_ssl_le_certificate(self, client: Gcore) -> None: - resource = client.cdn.resources.prevalidate_ssl_le_certificate( + cdn_resource = client.cdn.cdn_resources.prevalidate_ssl_le_certificate( 0, ) - assert resource is None + assert cdn_resource is None @parametrize def test_raw_response_prevalidate_ssl_le_certificate(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.prevalidate_ssl_le_certificate( + response = client.cdn.cdn_resources.with_raw_response.prevalidate_ssl_le_certificate( 0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None @parametrize def test_streaming_response_prevalidate_ssl_le_certificate(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.prevalidate_ssl_le_certificate( + with client.cdn.cdn_resources.with_streaming_response.prevalidate_ssl_le_certificate( 0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize def test_method_purge_overload_1(self, client: Gcore) -> None: - resource = client.cdn.resources.purge( + cdn_resource = client.cdn.cdn_resources.purge( resource_id=0, ) - assert resource is None + assert cdn_resource is None @parametrize def test_method_purge_with_all_params_overload_1(self, client: Gcore) -> None: - resource = client.cdn.resources.purge( + cdn_resource = client.cdn.cdn_resources.purge( resource_id=0, urls=["/some-url.jpg", "/img/example.jpg"], ) - assert resource is None + assert cdn_resource is None @parametrize def test_raw_response_purge_overload_1(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.purge( + response = client.cdn.cdn_resources.with_raw_response.purge( resource_id=0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None @parametrize def test_streaming_response_purge_overload_1(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.purge( + with client.cdn.cdn_resources.with_streaming_response.purge( resource_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize def test_method_purge_overload_2(self, client: Gcore) -> None: - resource = client.cdn.resources.purge( + cdn_resource = client.cdn.cdn_resources.purge( resource_id=0, ) - assert resource is None + assert cdn_resource is None @parametrize def test_method_purge_with_all_params_overload_2(self, client: Gcore) -> None: - resource = client.cdn.resources.purge( + cdn_resource = client.cdn.cdn_resources.purge( resource_id=0, paths=["/images/*", "/videos/*"], ) - assert resource is None + assert cdn_resource is None @parametrize def test_raw_response_purge_overload_2(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.purge( + response = client.cdn.cdn_resources.with_raw_response.purge( resource_id=0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None @parametrize def test_streaming_response_purge_overload_2(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.purge( + with client.cdn.cdn_resources.with_streaming_response.purge( resource_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize def test_method_purge_overload_3(self, client: Gcore) -> None: - resource = client.cdn.resources.purge( + cdn_resource = client.cdn.cdn_resources.purge( resource_id=0, ) - assert resource is None + assert cdn_resource is None @parametrize def test_method_purge_with_all_params_overload_3(self, client: Gcore) -> None: - resource = client.cdn.resources.purge( + cdn_resource = client.cdn.cdn_resources.purge( resource_id=0, paths=["string"], ) - assert resource is None + assert cdn_resource is None @parametrize def test_raw_response_purge_overload_3(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.purge( + response = client.cdn.cdn_resources.with_raw_response.purge( resource_id=0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None @parametrize def test_streaming_response_purge_overload_3(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.purge( + with client.cdn.cdn_resources.with_streaming_response.purge( resource_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert resource is None + cdn_resource = response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize def test_method_replace(self, client: Gcore) -> None: - resource = client.cdn.resources.replace( + cdn_resource = client.cdn.cdn_resources.replace( resource_id=0, origin_group=132, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize def test_method_replace_with_all_params(self, client: Gcore) -> None: - resource = client.cdn.resources.replace( + cdn_resource = client.cdn.cdn_resources.replace( resource_id=0, origin_group=132, active=True, @@ -1281,7 +1281,7 @@ def test_method_replace_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -1302,52 +1302,52 @@ def test_method_replace_with_all_params(self, client: Gcore) -> None: ssl_enabled=False, waap_api_domain_enabled=True, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize def test_raw_response_replace(self, client: Gcore) -> None: - response = client.cdn.resources.with_raw_response.replace( + response = client.cdn.cdn_resources.with_raw_response.replace( resource_id=0, origin_group=132, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize def test_streaming_response_replace(self, client: Gcore) -> None: - with client.cdn.resources.with_streaming_response.replace( + with client.cdn.cdn_resources.with_streaming_response.replace( resource_id=0, origin_group=132, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True -class TestAsyncResources: +class TestAsyncCDNResources: parametrize = pytest.mark.parametrize( "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) @parametrize async def test_method_create(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.create( + cdn_resource = await async_client.cdn.cdn_resources.create( cname="cdn.site.com", origin="example.com", origin_group=132, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.create( + cdn_resource = await async_client.cdn.cdn_resources.create( cname="cdn.site.com", origin="example.com", origin_group=132, @@ -1627,7 +1627,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -1649,11 +1649,11 @@ async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> ssl_enabled=False, waap_api_domain_enabled=True, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.create( + response = await async_client.cdn.cdn_resources.with_raw_response.create( cname="cdn.site.com", origin="example.com", origin_group=132, @@ -1661,12 +1661,12 @@ async def test_raw_response_create(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.create( + async with async_client.cdn.cdn_resources.with_streaming_response.create( cname="cdn.site.com", origin="example.com", origin_group=132, @@ -1674,23 +1674,23 @@ async def test_streaming_response_create(self, async_client: AsyncGcore) -> None assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="unexpected prism python test failures") @parametrize async def test_method_update(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.update( + cdn_resource = await async_client.cdn.cdn_resources.update( resource_id=0, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @pytest.mark.skip(reason="unexpected prism python test failures") @parametrize async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.update( + cdn_resource = await async_client.cdn.cdn_resources.update( resource_id=0, active=True, description="My resource", @@ -1968,7 +1968,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -1989,42 +1989,42 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> ssl_data=192, ssl_enabled=False, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @pytest.mark.skip(reason="unexpected prism python test failures") @parametrize async def test_raw_response_update(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.update( + response = await async_client.cdn.cdn_resources.with_raw_response.update( resource_id=0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @pytest.mark.skip(reason="unexpected prism python test failures") @parametrize async def test_streaming_response_update(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.update( + async with async_client.cdn.cdn_resources.with_streaming_response.update( resource_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_list(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.list() - assert_matches_type(CdnResourceList, resource, path=["response"]) + cdn_resource = await async_client.cdn.cdn_resources.list() + assert_matches_type(CDNResourceList, cdn_resource, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.list( + cdn_resource = await async_client.cdn.cdn_resources.list( cname="cname", deleted=True, enabled=True, @@ -2042,283 +2042,283 @@ async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> No suspend=True, vp_enabled=True, ) - assert_matches_type(CdnResourceList, resource, path=["response"]) + assert_matches_type(CDNResourceList, cdn_resource, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.list() + response = await async_client.cdn.cdn_resources.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResourceList, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResourceList, cdn_resource, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.list() as response: + async with async_client.cdn.cdn_resources.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResourceList, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResourceList, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_delete(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.delete( + cdn_resource = await async_client.cdn.cdn_resources.delete( 0, ) - assert resource is None + assert cdn_resource is None @parametrize async def test_raw_response_delete(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.delete( + response = await async_client.cdn.cdn_resources.with_raw_response.delete( 0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None @parametrize async def test_streaming_response_delete(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.delete( + async with async_client.cdn.cdn_resources.with_streaming_response.delete( 0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize async def test_method_get(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.get( + cdn_resource = await async_client.cdn.cdn_resources.get( 0, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.get( + response = await async_client.cdn.cdn_resources.with_raw_response.get( 0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.get( + async with async_client.cdn.cdn_resources.with_streaming_response.get( 0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_prefetch(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.prefetch( + cdn_resource = await async_client.cdn.cdn_resources.prefetch( resource_id=0, paths=["/test.jpg", "test1.jpg"], ) - assert resource is None + assert cdn_resource is None @parametrize async def test_raw_response_prefetch(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.prefetch( + response = await async_client.cdn.cdn_resources.with_raw_response.prefetch( resource_id=0, paths=["/test.jpg", "test1.jpg"], ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None @parametrize async def test_streaming_response_prefetch(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.prefetch( + async with async_client.cdn.cdn_resources.with_streaming_response.prefetch( resource_id=0, paths=["/test.jpg", "test1.jpg"], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize async def test_method_prevalidate_ssl_le_certificate(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.prevalidate_ssl_le_certificate( + cdn_resource = await async_client.cdn.cdn_resources.prevalidate_ssl_le_certificate( 0, ) - assert resource is None + assert cdn_resource is None @parametrize async def test_raw_response_prevalidate_ssl_le_certificate(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.prevalidate_ssl_le_certificate( + response = await async_client.cdn.cdn_resources.with_raw_response.prevalidate_ssl_le_certificate( 0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None @parametrize async def test_streaming_response_prevalidate_ssl_le_certificate(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.prevalidate_ssl_le_certificate( + async with async_client.cdn.cdn_resources.with_streaming_response.prevalidate_ssl_le_certificate( 0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize async def test_method_purge_overload_1(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.purge( + cdn_resource = await async_client.cdn.cdn_resources.purge( resource_id=0, ) - assert resource is None + assert cdn_resource is None @parametrize async def test_method_purge_with_all_params_overload_1(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.purge( + cdn_resource = await async_client.cdn.cdn_resources.purge( resource_id=0, urls=["/some-url.jpg", "/img/example.jpg"], ) - assert resource is None + assert cdn_resource is None @parametrize async def test_raw_response_purge_overload_1(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.purge( + response = await async_client.cdn.cdn_resources.with_raw_response.purge( resource_id=0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None @parametrize async def test_streaming_response_purge_overload_1(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.purge( + async with async_client.cdn.cdn_resources.with_streaming_response.purge( resource_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize async def test_method_purge_overload_2(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.purge( + cdn_resource = await async_client.cdn.cdn_resources.purge( resource_id=0, ) - assert resource is None + assert cdn_resource is None @parametrize async def test_method_purge_with_all_params_overload_2(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.purge( + cdn_resource = await async_client.cdn.cdn_resources.purge( resource_id=0, paths=["/images/*", "/videos/*"], ) - assert resource is None + assert cdn_resource is None @parametrize async def test_raw_response_purge_overload_2(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.purge( + response = await async_client.cdn.cdn_resources.with_raw_response.purge( resource_id=0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None @parametrize async def test_streaming_response_purge_overload_2(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.purge( + async with async_client.cdn.cdn_resources.with_streaming_response.purge( resource_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize async def test_method_purge_overload_3(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.purge( + cdn_resource = await async_client.cdn.cdn_resources.purge( resource_id=0, ) - assert resource is None + assert cdn_resource is None @parametrize async def test_method_purge_with_all_params_overload_3(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.purge( + cdn_resource = await async_client.cdn.cdn_resources.purge( resource_id=0, paths=["string"], ) - assert resource is None + assert cdn_resource is None @parametrize async def test_raw_response_purge_overload_3(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.purge( + response = await async_client.cdn.cdn_resources.with_raw_response.purge( resource_id=0, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None @parametrize async def test_streaming_response_purge_overload_3(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.purge( + async with async_client.cdn.cdn_resources.with_streaming_response.purge( resource_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert resource is None + cdn_resource = await response.parse() + assert cdn_resource is None assert cast(Any, response.is_closed) is True @parametrize async def test_method_replace(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.replace( + cdn_resource = await async_client.cdn.cdn_resources.replace( resource_id=0, origin_group=132, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> None: - resource = await async_client.cdn.resources.replace( + cdn_resource = await async_client.cdn.cdn_resources.replace( resource_id=0, origin_group=132, active=True, @@ -2597,7 +2597,7 @@ async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -2618,30 +2618,30 @@ async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> ssl_enabled=False, waap_api_domain_enabled=True, ) - assert_matches_type(CdnResource, resource, path=["response"]) + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize async def test_raw_response_replace(self, async_client: AsyncGcore) -> None: - response = await async_client.cdn.resources.with_raw_response.replace( + response = await async_client.cdn.cdn_resources.with_raw_response.replace( resource_id=0, origin_group=132, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) @parametrize async def test_streaming_response_replace(self, async_client: AsyncGcore) -> None: - async with async_client.cdn.resources.with_streaming_response.replace( + async with async_client.cdn.cdn_resources.with_streaming_response.replace( resource_id=0, origin_group=132, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(CdnResource, resource, path=["response"]) + cdn_resource = await response.parse() + assert_matches_type(CDNResource, cdn_resource, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cdn/test_logs.py b/tests/api_resources/cdn/test_logs.py index c585876e..f72d4e71 100644 --- a/tests/api_resources/cdn/test_logs.py +++ b/tests/api_resources/cdn/test_logs.py @@ -17,7 +17,7 @@ StreamedBinaryAPIResponse, AsyncStreamedBinaryAPIResponse, ) -from gcore.pagination import SyncOffsetPageCdnLogs, AsyncOffsetPageCdnLogs +from gcore.pagination import SyncOffsetPageCDNLogs, AsyncOffsetPageCDNLogs from gcore.types.cdn.cdn_log_entry import Data base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -32,7 +32,7 @@ def test_method_list(self, client: Gcore) -> None: from_="from", to="to", ) - assert_matches_type(SyncOffsetPageCdnLogs[Data], log, path=["response"]) + assert_matches_type(SyncOffsetPageCDNLogs[Data], log, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Gcore) -> None: @@ -89,7 +89,7 @@ def test_method_list_with_all_params(self, client: Gcore) -> None: status_ne=0, status_not_in="status__not_in", ) - assert_matches_type(SyncOffsetPageCdnLogs[Data], log, path=["response"]) + assert_matches_type(SyncOffsetPageCDNLogs[Data], log, path=["response"]) @parametrize def test_raw_response_list(self, client: Gcore) -> None: @@ -101,7 +101,7 @@ def test_raw_response_list(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" log = response.parse() - assert_matches_type(SyncOffsetPageCdnLogs[Data], log, path=["response"]) + assert_matches_type(SyncOffsetPageCDNLogs[Data], log, path=["response"]) @parametrize def test_streaming_response_list(self, client: Gcore) -> None: @@ -113,7 +113,7 @@ def test_streaming_response_list(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" log = response.parse() - assert_matches_type(SyncOffsetPageCdnLogs[Data], log, path=["response"]) + assert_matches_type(SyncOffsetPageCDNLogs[Data], log, path=["response"]) assert cast(Any, response.is_closed) is True @@ -240,7 +240,7 @@ async def test_method_list(self, async_client: AsyncGcore) -> None: from_="from", to="to", ) - assert_matches_type(AsyncOffsetPageCdnLogs[Data], log, path=["response"]) + assert_matches_type(AsyncOffsetPageCDNLogs[Data], log, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> None: @@ -297,7 +297,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> No status_ne=0, status_not_in="status__not_in", ) - assert_matches_type(AsyncOffsetPageCdnLogs[Data], log, path=["response"]) + assert_matches_type(AsyncOffsetPageCDNLogs[Data], log, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncGcore) -> None: @@ -309,7 +309,7 @@ async def test_raw_response_list(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" log = await response.parse() - assert_matches_type(AsyncOffsetPageCdnLogs[Data], log, path=["response"]) + assert_matches_type(AsyncOffsetPageCDNLogs[Data], log, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: @@ -321,7 +321,7 @@ async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" log = await response.parse() - assert_matches_type(AsyncOffsetPageCdnLogs[Data], log, path=["response"]) + assert_matches_type(AsyncOffsetPageCDNLogs[Data], log, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cdn/test_metrics.py b/tests/api_resources/cdn/test_metrics.py index dcfd8767..40040587 100644 --- a/tests/api_resources/cdn/test_metrics.py +++ b/tests/api_resources/cdn/test_metrics.py @@ -9,7 +9,7 @@ from gcore import Gcore, AsyncGcore from tests.utils import assert_matches_type -from gcore.types.cdn import CdnMetrics +from gcore.types.cdn import CDNMetrics base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -24,7 +24,7 @@ def test_method_list(self, client: Gcore) -> None: metrics=["edge_status_2xx", "edge_status_3xx", "edge_status_4xx", "edge_status_5xx"], to="2021-06-15T00:00:00Z", ) - assert_matches_type(CdnMetrics, metric, path=["response"]) + assert_matches_type(CDNMetrics, metric, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Gcore) -> None: @@ -42,7 +42,7 @@ def test_method_list_with_all_params(self, client: Gcore) -> None: granularity="P1D", group_by=["cname"], ) - assert_matches_type(CdnMetrics, metric, path=["response"]) + assert_matches_type(CDNMetrics, metric, path=["response"]) @parametrize def test_raw_response_list(self, client: Gcore) -> None: @@ -55,7 +55,7 @@ def test_raw_response_list(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" metric = response.parse() - assert_matches_type(CdnMetrics, metric, path=["response"]) + assert_matches_type(CDNMetrics, metric, path=["response"]) @parametrize def test_streaming_response_list(self, client: Gcore) -> None: @@ -68,7 +68,7 @@ def test_streaming_response_list(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" metric = response.parse() - assert_matches_type(CdnMetrics, metric, path=["response"]) + assert_matches_type(CDNMetrics, metric, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ async def test_method_list(self, async_client: AsyncGcore) -> None: metrics=["edge_status_2xx", "edge_status_3xx", "edge_status_4xx", "edge_status_5xx"], to="2021-06-15T00:00:00Z", ) - assert_matches_type(CdnMetrics, metric, path=["response"]) + assert_matches_type(CDNMetrics, metric, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> None: @@ -103,7 +103,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncGcore) -> No granularity="P1D", group_by=["cname"], ) - assert_matches_type(CdnMetrics, metric, path=["response"]) + assert_matches_type(CDNMetrics, metric, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncGcore) -> None: @@ -116,7 +116,7 @@ async def test_raw_response_list(self, async_client: AsyncGcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" metric = await response.parse() - assert_matches_type(CdnMetrics, metric, path=["response"]) + assert_matches_type(CDNMetrics, metric, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: @@ -129,6 +129,6 @@ async def test_streaming_response_list(self, async_client: AsyncGcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" metric = await response.parse() - assert_matches_type(CdnMetrics, metric, path=["response"]) + assert_matches_type(CDNMetrics, metric, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cdn/test_rule_templates.py b/tests/api_resources/cdn/test_rule_templates.py index cf4af42c..e7d8cb23 100644 --- a/tests/api_resources/cdn/test_rule_templates.py +++ b/tests/api_resources/cdn/test_rule_templates.py @@ -287,7 +287,7 @@ def test_method_create_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -595,7 +595,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -994,7 +994,7 @@ def test_method_replace_with_all_params(self, client: Gcore) -> None: }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -1312,7 +1312,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -1620,7 +1620,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { @@ -2019,7 +2019,7 @@ async def test_method_replace_with_all_params(self, async_client: AsyncGcore) -> }, "user_agent_acl": { "enabled": True, - "excepted_values": ["UserAgent Value", ""], + "excepted_values": ["UserAgent Value", "~*.*bot.*", ""], "policy_type": "allow", }, "waap": { diff --git a/tests/api_resources/streaming/test_statistics.py b/tests/api_resources/streaming/test_statistics.py index bae1314e..35093360 100644 --- a/tests/api_resources/streaming/test_statistics.py +++ b/tests/api_resources/streaming/test_statistics.py @@ -23,12 +23,12 @@ ViewsByReferer, MaxStreamSeries, ViewsByHostname, - UniqueViewersCdn, + UniqueViewersCDN, VodStatisticsSeries, ViewsByOperatingSystem, VodTotalStreamDurationSeries, StatisticGetLiveUniqueViewersResponse, - StatisticGetVodWatchTimeTotalCdnResponse, + StatisticGetVodWatchTimeTotalCDNResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -424,7 +424,7 @@ def test_method_get_unique_viewers_cdn(self, client: Gcore) -> None: date_from="date_from", date_to="date_to", ) - assert_matches_type(UniqueViewersCdn, statistic, path=["response"]) + assert_matches_type(UniqueViewersCDN, statistic, path=["response"]) @parametrize def test_method_get_unique_viewers_cdn_with_all_params(self, client: Gcore) -> None: @@ -434,7 +434,7 @@ def test_method_get_unique_viewers_cdn_with_all_params(self, client: Gcore) -> N id="id", type="live", ) - assert_matches_type(UniqueViewersCdn, statistic, path=["response"]) + assert_matches_type(UniqueViewersCDN, statistic, path=["response"]) @parametrize def test_raw_response_get_unique_viewers_cdn(self, client: Gcore) -> None: @@ -446,7 +446,7 @@ def test_raw_response_get_unique_viewers_cdn(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" statistic = response.parse() - assert_matches_type(UniqueViewersCdn, statistic, path=["response"]) + assert_matches_type(UniqueViewersCDN, statistic, path=["response"]) @parametrize def test_streaming_response_get_unique_viewers_cdn(self, client: Gcore) -> None: @@ -458,7 +458,7 @@ def test_streaming_response_get_unique_viewers_cdn(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" statistic = response.parse() - assert_matches_type(UniqueViewersCdn, statistic, path=["response"]) + assert_matches_type(UniqueViewersCDN, statistic, path=["response"]) assert cast(Any, response.is_closed) is True @@ -912,7 +912,7 @@ def test_streaming_response_get_vod_watch_time_cdn(self, client: Gcore) -> None: @parametrize def test_method_get_vod_watch_time_total_cdn(self, client: Gcore) -> None: statistic = client.streaming.statistics.get_vod_watch_time_total_cdn() - assert_matches_type(StatisticGetVodWatchTimeTotalCdnResponse, statistic, path=["response"]) + assert_matches_type(StatisticGetVodWatchTimeTotalCDNResponse, statistic, path=["response"]) @parametrize def test_method_get_vod_watch_time_total_cdn_with_all_params(self, client: Gcore) -> None: @@ -922,7 +922,7 @@ def test_method_get_vod_watch_time_total_cdn_with_all_params(self, client: Gcore slug="slug", to="to", ) - assert_matches_type(StatisticGetVodWatchTimeTotalCdnResponse, statistic, path=["response"]) + assert_matches_type(StatisticGetVodWatchTimeTotalCDNResponse, statistic, path=["response"]) @parametrize def test_raw_response_get_vod_watch_time_total_cdn(self, client: Gcore) -> None: @@ -931,7 +931,7 @@ def test_raw_response_get_vod_watch_time_total_cdn(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" statistic = response.parse() - assert_matches_type(StatisticGetVodWatchTimeTotalCdnResponse, statistic, path=["response"]) + assert_matches_type(StatisticGetVodWatchTimeTotalCDNResponse, statistic, path=["response"]) @parametrize def test_streaming_response_get_vod_watch_time_total_cdn(self, client: Gcore) -> None: @@ -940,7 +940,7 @@ def test_streaming_response_get_vod_watch_time_total_cdn(self, client: Gcore) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" statistic = response.parse() - assert_matches_type(StatisticGetVodWatchTimeTotalCdnResponse, statistic, path=["response"]) + assert_matches_type(StatisticGetVodWatchTimeTotalCDNResponse, statistic, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1339,7 +1339,7 @@ async def test_method_get_unique_viewers_cdn(self, async_client: AsyncGcore) -> date_from="date_from", date_to="date_to", ) - assert_matches_type(UniqueViewersCdn, statistic, path=["response"]) + assert_matches_type(UniqueViewersCDN, statistic, path=["response"]) @parametrize async def test_method_get_unique_viewers_cdn_with_all_params(self, async_client: AsyncGcore) -> None: @@ -1349,7 +1349,7 @@ async def test_method_get_unique_viewers_cdn_with_all_params(self, async_client: id="id", type="live", ) - assert_matches_type(UniqueViewersCdn, statistic, path=["response"]) + assert_matches_type(UniqueViewersCDN, statistic, path=["response"]) @parametrize async def test_raw_response_get_unique_viewers_cdn(self, async_client: AsyncGcore) -> None: @@ -1361,7 +1361,7 @@ async def test_raw_response_get_unique_viewers_cdn(self, async_client: AsyncGcor assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" statistic = await response.parse() - assert_matches_type(UniqueViewersCdn, statistic, path=["response"]) + assert_matches_type(UniqueViewersCDN, statistic, path=["response"]) @parametrize async def test_streaming_response_get_unique_viewers_cdn(self, async_client: AsyncGcore) -> None: @@ -1373,7 +1373,7 @@ async def test_streaming_response_get_unique_viewers_cdn(self, async_client: Asy assert response.http_request.headers.get("X-Stainless-Lang") == "python" statistic = await response.parse() - assert_matches_type(UniqueViewersCdn, statistic, path=["response"]) + assert_matches_type(UniqueViewersCDN, statistic, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1827,7 +1827,7 @@ async def test_streaming_response_get_vod_watch_time_cdn(self, async_client: Asy @parametrize async def test_method_get_vod_watch_time_total_cdn(self, async_client: AsyncGcore) -> None: statistic = await async_client.streaming.statistics.get_vod_watch_time_total_cdn() - assert_matches_type(StatisticGetVodWatchTimeTotalCdnResponse, statistic, path=["response"]) + assert_matches_type(StatisticGetVodWatchTimeTotalCDNResponse, statistic, path=["response"]) @parametrize async def test_method_get_vod_watch_time_total_cdn_with_all_params(self, async_client: AsyncGcore) -> None: @@ -1837,7 +1837,7 @@ async def test_method_get_vod_watch_time_total_cdn_with_all_params(self, async_c slug="slug", to="to", ) - assert_matches_type(StatisticGetVodWatchTimeTotalCdnResponse, statistic, path=["response"]) + assert_matches_type(StatisticGetVodWatchTimeTotalCDNResponse, statistic, path=["response"]) @parametrize async def test_raw_response_get_vod_watch_time_total_cdn(self, async_client: AsyncGcore) -> None: @@ -1846,7 +1846,7 @@ async def test_raw_response_get_vod_watch_time_total_cdn(self, async_client: Asy assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" statistic = await response.parse() - assert_matches_type(StatisticGetVodWatchTimeTotalCdnResponse, statistic, path=["response"]) + assert_matches_type(StatisticGetVodWatchTimeTotalCDNResponse, statistic, path=["response"]) @parametrize async def test_streaming_response_get_vod_watch_time_total_cdn(self, async_client: AsyncGcore) -> None: @@ -1855,6 +1855,6 @@ async def test_streaming_response_get_vod_watch_time_total_cdn(self, async_clien assert response.http_request.headers.get("X-Stainless-Lang") == "python" statistic = await response.parse() - assert_matches_type(StatisticGetVodWatchTimeTotalCdnResponse, statistic, path=["response"]) + assert_matches_type(StatisticGetVodWatchTimeTotalCDNResponse, statistic, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_cdn.py b/tests/api_resources/test_cdn.py index 97c7b598..153a1094 100644 --- a/tests/api_resources/test_cdn.py +++ b/tests/api_resources/test_cdn.py @@ -11,23 +11,23 @@ from tests.utils import assert_matches_type from gcore.types.cdn import ( AwsRegions, - CdnAccount, + CDNAccount, AlibabaRegions, - CdnAccountLimits, - CdnAvailableFeatures, - CdnListPurgeStatusesResponse, + CDNAccountLimits, + CDNAvailableFeatures, + CDNListPurgeStatusesResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -class TestCdn: +class TestCDN: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize def test_method_get_account_limits(self, client: Gcore) -> None: cdn = client.cdn.get_account_limits() - assert_matches_type(CdnAccountLimits, cdn, path=["response"]) + assert_matches_type(CDNAccountLimits, cdn, path=["response"]) @parametrize def test_raw_response_get_account_limits(self, client: Gcore) -> None: @@ -36,7 +36,7 @@ def test_raw_response_get_account_limits(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnAccountLimits, cdn, path=["response"]) + assert_matches_type(CDNAccountLimits, cdn, path=["response"]) @parametrize def test_streaming_response_get_account_limits(self, client: Gcore) -> None: @@ -45,14 +45,14 @@ def test_streaming_response_get_account_limits(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnAccountLimits, cdn, path=["response"]) + assert_matches_type(CDNAccountLimits, cdn, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_get_account_overview(self, client: Gcore) -> None: cdn = client.cdn.get_account_overview() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize def test_raw_response_get_account_overview(self, client: Gcore) -> None: @@ -61,7 +61,7 @@ def test_raw_response_get_account_overview(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize def test_streaming_response_get_account_overview(self, client: Gcore) -> None: @@ -70,14 +70,14 @@ def test_streaming_response_get_account_overview(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_get_available_features(self, client: Gcore) -> None: cdn = client.cdn.get_available_features() - assert_matches_type(CdnAvailableFeatures, cdn, path=["response"]) + assert_matches_type(CDNAvailableFeatures, cdn, path=["response"]) @parametrize def test_raw_response_get_available_features(self, client: Gcore) -> None: @@ -86,7 +86,7 @@ def test_raw_response_get_available_features(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnAvailableFeatures, cdn, path=["response"]) + assert_matches_type(CDNAvailableFeatures, cdn, path=["response"]) @parametrize def test_streaming_response_get_available_features(self, client: Gcore) -> None: @@ -95,7 +95,7 @@ def test_streaming_response_get_available_features(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnAvailableFeatures, cdn, path=["response"]) + assert_matches_type(CDNAvailableFeatures, cdn, path=["response"]) assert cast(Any, response.is_closed) is True @@ -152,7 +152,7 @@ def test_streaming_response_list_aws_regions(self, client: Gcore) -> None: @parametrize def test_method_list_purge_statuses(self, client: Gcore) -> None: cdn = client.cdn.list_purge_statuses() - assert_matches_type(CdnListPurgeStatusesResponse, cdn, path=["response"]) + assert_matches_type(CDNListPurgeStatusesResponse, cdn, path=["response"]) @parametrize def test_method_list_purge_statuses_with_all_params(self, client: Gcore) -> None: @@ -165,7 +165,7 @@ def test_method_list_purge_statuses_with_all_params(self, client: Gcore) -> None status="status", to_created="to_created", ) - assert_matches_type(CdnListPurgeStatusesResponse, cdn, path=["response"]) + assert_matches_type(CDNListPurgeStatusesResponse, cdn, path=["response"]) @parametrize def test_raw_response_list_purge_statuses(self, client: Gcore) -> None: @@ -174,7 +174,7 @@ def test_raw_response_list_purge_statuses(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnListPurgeStatusesResponse, cdn, path=["response"]) + assert_matches_type(CDNListPurgeStatusesResponse, cdn, path=["response"]) @parametrize def test_streaming_response_list_purge_statuses(self, client: Gcore) -> None: @@ -183,21 +183,21 @@ def test_streaming_response_list_purge_statuses(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnListPurgeStatusesResponse, cdn, path=["response"]) + assert_matches_type(CDNListPurgeStatusesResponse, cdn, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_update_account(self, client: Gcore) -> None: cdn = client.cdn.update_account() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize def test_method_update_account_with_all_params(self, client: Gcore) -> None: cdn = client.cdn.update_account( utilization_level=1111, ) - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize def test_raw_response_update_account(self, client: Gcore) -> None: @@ -206,7 +206,7 @@ def test_raw_response_update_account(self, client: Gcore) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize def test_streaming_response_update_account(self, client: Gcore) -> None: @@ -215,12 +215,12 @@ def test_streaming_response_update_account(self, client: Gcore) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = response.parse() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) assert cast(Any, response.is_closed) is True -class TestAsyncCdn: +class TestAsyncCDN: parametrize = pytest.mark.parametrize( "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) @@ -228,7 +228,7 @@ class TestAsyncCdn: @parametrize async def test_method_get_account_limits(self, async_client: AsyncGcore) -> None: cdn = await async_client.cdn.get_account_limits() - assert_matches_type(CdnAccountLimits, cdn, path=["response"]) + assert_matches_type(CDNAccountLimits, cdn, path=["response"]) @parametrize async def test_raw_response_get_account_limits(self, async_client: AsyncGcore) -> None: @@ -237,7 +237,7 @@ async def test_raw_response_get_account_limits(self, async_client: AsyncGcore) - assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnAccountLimits, cdn, path=["response"]) + assert_matches_type(CDNAccountLimits, cdn, path=["response"]) @parametrize async def test_streaming_response_get_account_limits(self, async_client: AsyncGcore) -> None: @@ -246,14 +246,14 @@ async def test_streaming_response_get_account_limits(self, async_client: AsyncGc assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnAccountLimits, cdn, path=["response"]) + assert_matches_type(CDNAccountLimits, cdn, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_get_account_overview(self, async_client: AsyncGcore) -> None: cdn = await async_client.cdn.get_account_overview() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize async def test_raw_response_get_account_overview(self, async_client: AsyncGcore) -> None: @@ -262,7 +262,7 @@ async def test_raw_response_get_account_overview(self, async_client: AsyncGcore) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize async def test_streaming_response_get_account_overview(self, async_client: AsyncGcore) -> None: @@ -271,14 +271,14 @@ async def test_streaming_response_get_account_overview(self, async_client: Async assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_get_available_features(self, async_client: AsyncGcore) -> None: cdn = await async_client.cdn.get_available_features() - assert_matches_type(CdnAvailableFeatures, cdn, path=["response"]) + assert_matches_type(CDNAvailableFeatures, cdn, path=["response"]) @parametrize async def test_raw_response_get_available_features(self, async_client: AsyncGcore) -> None: @@ -287,7 +287,7 @@ async def test_raw_response_get_available_features(self, async_client: AsyncGcor assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnAvailableFeatures, cdn, path=["response"]) + assert_matches_type(CDNAvailableFeatures, cdn, path=["response"]) @parametrize async def test_streaming_response_get_available_features(self, async_client: AsyncGcore) -> None: @@ -296,7 +296,7 @@ async def test_streaming_response_get_available_features(self, async_client: Asy assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnAvailableFeatures, cdn, path=["response"]) + assert_matches_type(CDNAvailableFeatures, cdn, path=["response"]) assert cast(Any, response.is_closed) is True @@ -353,7 +353,7 @@ async def test_streaming_response_list_aws_regions(self, async_client: AsyncGcor @parametrize async def test_method_list_purge_statuses(self, async_client: AsyncGcore) -> None: cdn = await async_client.cdn.list_purge_statuses() - assert_matches_type(CdnListPurgeStatusesResponse, cdn, path=["response"]) + assert_matches_type(CDNListPurgeStatusesResponse, cdn, path=["response"]) @parametrize async def test_method_list_purge_statuses_with_all_params(self, async_client: AsyncGcore) -> None: @@ -366,7 +366,7 @@ async def test_method_list_purge_statuses_with_all_params(self, async_client: As status="status", to_created="to_created", ) - assert_matches_type(CdnListPurgeStatusesResponse, cdn, path=["response"]) + assert_matches_type(CDNListPurgeStatusesResponse, cdn, path=["response"]) @parametrize async def test_raw_response_list_purge_statuses(self, async_client: AsyncGcore) -> None: @@ -375,7 +375,7 @@ async def test_raw_response_list_purge_statuses(self, async_client: AsyncGcore) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnListPurgeStatusesResponse, cdn, path=["response"]) + assert_matches_type(CDNListPurgeStatusesResponse, cdn, path=["response"]) @parametrize async def test_streaming_response_list_purge_statuses(self, async_client: AsyncGcore) -> None: @@ -384,21 +384,21 @@ async def test_streaming_response_list_purge_statuses(self, async_client: AsyncG assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnListPurgeStatusesResponse, cdn, path=["response"]) + assert_matches_type(CDNListPurgeStatusesResponse, cdn, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_update_account(self, async_client: AsyncGcore) -> None: cdn = await async_client.cdn.update_account() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize async def test_method_update_account_with_all_params(self, async_client: AsyncGcore) -> None: cdn = await async_client.cdn.update_account( utilization_level=1111, ) - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize async def test_raw_response_update_account(self, async_client: AsyncGcore) -> None: @@ -407,7 +407,7 @@ async def test_raw_response_update_account(self, async_client: AsyncGcore) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) @parametrize async def test_streaming_response_update_account(self, async_client: AsyncGcore) -> None: @@ -416,6 +416,6 @@ async def test_streaming_response_update_account(self, async_client: AsyncGcore) assert response.http_request.headers.get("X-Stainless-Lang") == "python" cdn = await response.parse() - assert_matches_type(CdnAccount, cdn, path=["response"]) + assert_matches_type(CDNAccount, cdn, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/waap/domains/test_statistics.py b/tests/api_resources/waap/domains/test_statistics.py index f46a30a2..c8a4bcb4 100644 --- a/tests/api_resources/waap/domains/test_statistics.py +++ b/tests/api_resources/waap/domains/test_statistics.py @@ -20,6 +20,8 @@ StatisticGetTrafficSeriesResponse, ) +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -131,7 +133,7 @@ def test_method_get_events_aggregated_with_all_params(self, client: Gcore) -> No statistic = client.waap.domains.statistics.get_events_aggregated( domain_id=1, start="2024-04-13T00:00:00+01:00", - action=["block", "captcha"], + action=["allow", "block"], end="2024-04-14T12:00:00Z", ip=["string", "string"], reference_id=["string", "string"], @@ -209,37 +211,42 @@ def test_path_params_get_request_details(self, client: Gcore) -> None: @parametrize def test_method_get_requests_series(self, client: Gcore) -> None: - statistic = client.waap.domains.statistics.get_requests_series( - domain_id=1, - start="2024-04-13T00:00:00+01:00", - ) + with pytest.warns(DeprecationWarning): + statistic = client.waap.domains.statistics.get_requests_series( + domain_id=1, + start="2024-04-13T00:00:00+01:00", + ) + assert_matches_type(SyncOffsetPage[WaapRequestSummary], statistic, path=["response"]) @parametrize def test_method_get_requests_series_with_all_params(self, client: Gcore) -> None: - statistic = client.waap.domains.statistics.get_requests_series( - domain_id=1, - start="2024-04-13T00:00:00+01:00", - actions=["allow"], - countries=["Mv"], - end="2024-04-14T12:00:00Z", - ip=".:", - limit=0, - offset=0, - ordering="ordering", - reference_id="ad07c06f19054e484974fa22e9fb6bb1", - security_rule_name="security_rule_name", - status_code=100, - traffic_types=["policy_allowed"], - ) + with pytest.warns(DeprecationWarning): + statistic = client.waap.domains.statistics.get_requests_series( + domain_id=1, + start="2024-04-13T00:00:00+01:00", + actions=["allow"], + countries=["Mv"], + end="2024-04-14T12:00:00Z", + ip=".:", + limit=0, + offset=0, + ordering="ordering", + reference_id="ad07c06f19054e484974fa22e9fb6bb1", + security_rule_name="security_rule_name", + status_code=100, + traffic_types=["policy_allowed"], + ) + assert_matches_type(SyncOffsetPage[WaapRequestSummary], statistic, path=["response"]) @parametrize def test_raw_response_get_requests_series(self, client: Gcore) -> None: - response = client.waap.domains.statistics.with_raw_response.get_requests_series( - domain_id=1, - start="2024-04-13T00:00:00+01:00", - ) + with pytest.warns(DeprecationWarning): + response = client.waap.domains.statistics.with_raw_response.get_requests_series( + domain_id=1, + start="2024-04-13T00:00:00+01:00", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -248,15 +255,16 @@ def test_raw_response_get_requests_series(self, client: Gcore) -> None: @parametrize def test_streaming_response_get_requests_series(self, client: Gcore) -> None: - with client.waap.domains.statistics.with_streaming_response.get_requests_series( - domain_id=1, - start="2024-04-13T00:00:00+01:00", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.waap.domains.statistics.with_streaming_response.get_requests_series( + domain_id=1, + start="2024-04-13T00:00:00+01:00", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - statistic = response.parse() - assert_matches_type(SyncOffsetPage[WaapRequestSummary], statistic, path=["response"]) + statistic = response.parse() + assert_matches_type(SyncOffsetPage[WaapRequestSummary], statistic, path=["response"]) assert cast(Any, response.is_closed) is True @@ -418,7 +426,7 @@ async def test_method_get_events_aggregated_with_all_params(self, async_client: statistic = await async_client.waap.domains.statistics.get_events_aggregated( domain_id=1, start="2024-04-13T00:00:00+01:00", - action=["block", "captcha"], + action=["allow", "block"], end="2024-04-14T12:00:00Z", ip=["string", "string"], reference_id=["string", "string"], @@ -496,37 +504,42 @@ async def test_path_params_get_request_details(self, async_client: AsyncGcore) - @parametrize async def test_method_get_requests_series(self, async_client: AsyncGcore) -> None: - statistic = await async_client.waap.domains.statistics.get_requests_series( - domain_id=1, - start="2024-04-13T00:00:00+01:00", - ) + with pytest.warns(DeprecationWarning): + statistic = await async_client.waap.domains.statistics.get_requests_series( + domain_id=1, + start="2024-04-13T00:00:00+01:00", + ) + assert_matches_type(AsyncOffsetPage[WaapRequestSummary], statistic, path=["response"]) @parametrize async def test_method_get_requests_series_with_all_params(self, async_client: AsyncGcore) -> None: - statistic = await async_client.waap.domains.statistics.get_requests_series( - domain_id=1, - start="2024-04-13T00:00:00+01:00", - actions=["allow"], - countries=["Mv"], - end="2024-04-14T12:00:00Z", - ip=".:", - limit=0, - offset=0, - ordering="ordering", - reference_id="ad07c06f19054e484974fa22e9fb6bb1", - security_rule_name="security_rule_name", - status_code=100, - traffic_types=["policy_allowed"], - ) + with pytest.warns(DeprecationWarning): + statistic = await async_client.waap.domains.statistics.get_requests_series( + domain_id=1, + start="2024-04-13T00:00:00+01:00", + actions=["allow"], + countries=["Mv"], + end="2024-04-14T12:00:00Z", + ip=".:", + limit=0, + offset=0, + ordering="ordering", + reference_id="ad07c06f19054e484974fa22e9fb6bb1", + security_rule_name="security_rule_name", + status_code=100, + traffic_types=["policy_allowed"], + ) + assert_matches_type(AsyncOffsetPage[WaapRequestSummary], statistic, path=["response"]) @parametrize async def test_raw_response_get_requests_series(self, async_client: AsyncGcore) -> None: - response = await async_client.waap.domains.statistics.with_raw_response.get_requests_series( - domain_id=1, - start="2024-04-13T00:00:00+01:00", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.waap.domains.statistics.with_raw_response.get_requests_series( + domain_id=1, + start="2024-04-13T00:00:00+01:00", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -535,15 +548,16 @@ async def test_raw_response_get_requests_series(self, async_client: AsyncGcore) @parametrize async def test_streaming_response_get_requests_series(self, async_client: AsyncGcore) -> None: - async with async_client.waap.domains.statistics.with_streaming_response.get_requests_series( - domain_id=1, - start="2024-04-13T00:00:00+01:00", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.waap.domains.statistics.with_streaming_response.get_requests_series( + domain_id=1, + start="2024-04-13T00:00:00+01:00", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - statistic = await response.parse() - assert_matches_type(AsyncOffsetPage[WaapRequestSummary], statistic, path=["response"]) + statistic = await response.parse() + assert_matches_type(AsyncOffsetPage[WaapRequestSummary], statistic, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/test_utils/test_json.py b/tests/test_utils/test_json.py new file mode 100644 index 00000000..9e4ec0e5 --- /dev/null +++ b/tests/test_utils/test_json.py @@ -0,0 +1,126 @@ +from __future__ import annotations + +import datetime +from typing import Union + +import pydantic + +from gcore import _compat +from gcore._utils._json import openapi_dumps + + +class TestOpenapiDumps: + def test_basic(self) -> None: + data = {"key": "value", "number": 42} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"key":"value","number":42}' + + def test_datetime_serialization(self) -> None: + dt = datetime.datetime(2023, 1, 1, 12, 0, 0) + data = {"datetime": dt} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"datetime":"2023-01-01T12:00:00"}' + + def test_pydantic_model_serialization(self) -> None: + class User(pydantic.BaseModel): + first_name: str + last_name: str + age: int + + model_instance = User(first_name="John", last_name="Kramer", age=83) + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"first_name":"John","last_name":"Kramer","age":83}}' + + def test_pydantic_model_with_default_values(self) -> None: + class User(pydantic.BaseModel): + name: str + role: str = "user" + active: bool = True + score: int = 0 + + model_instance = User(name="Alice") + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"name":"Alice"}}' + + def test_pydantic_model_with_default_values_overridden(self) -> None: + class User(pydantic.BaseModel): + name: str + role: str = "user" + active: bool = True + + model_instance = User(name="Bob", role="admin", active=False) + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"name":"Bob","role":"admin","active":false}}' + + def test_pydantic_model_with_alias(self) -> None: + class User(pydantic.BaseModel): + first_name: str = pydantic.Field(alias="firstName") + last_name: str = pydantic.Field(alias="lastName") + + model_instance = User(firstName="John", lastName="Doe") + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"firstName":"John","lastName":"Doe"}}' + + def test_pydantic_model_with_alias_and_default(self) -> None: + class User(pydantic.BaseModel): + user_name: str = pydantic.Field(alias="userName") + user_role: str = pydantic.Field(default="member", alias="userRole") + is_active: bool = pydantic.Field(default=True, alias="isActive") + + model_instance = User(userName="charlie") + data = {"model": model_instance} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"userName":"charlie"}}' + + model_with_overrides = User(userName="diana", userRole="admin", isActive=False) + data = {"model": model_with_overrides} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"userName":"diana","userRole":"admin","isActive":false}}' + + def test_pydantic_model_with_nested_models_and_defaults(self) -> None: + class Address(pydantic.BaseModel): + street: str + city: str = "Unknown" + + class User(pydantic.BaseModel): + name: str + address: Address + verified: bool = False + + if _compat.PYDANTIC_V1: + # to handle forward references in Pydantic v1 + User.update_forward_refs(**locals()) # type: ignore[reportDeprecated] + + address = Address(street="123 Main St") + user = User(name="Diana", address=address) + data = {"user": user} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"user":{"name":"Diana","address":{"street":"123 Main St"}}}' + + address_with_city = Address(street="456 Oak Ave", city="Boston") + user_verified = User(name="Eve", address=address_with_city, verified=True) + data = {"user": user_verified} + json_bytes = openapi_dumps(data) + assert ( + json_bytes == b'{"user":{"name":"Eve","address":{"street":"456 Oak Ave","city":"Boston"},"verified":true}}' + ) + + def test_pydantic_model_with_optional_fields(self) -> None: + class User(pydantic.BaseModel): + name: str + email: Union[str, None] + phone: Union[str, None] + + model_with_none = User(name="Eve", email=None, phone=None) + data = {"model": model_with_none} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"name":"Eve","email":null,"phone":null}}' + + model_with_values = User(name="Frank", email="frank@example.com", phone=None) + data = {"model": model_with_values} + json_bytes = openapi_dumps(data) + assert json_bytes == b'{"model":{"name":"Frank","email":"frank@example.com","phone":null}}'