diff --git a/services/cdn/src/stackit/cdn/__init__.py b/services/cdn/src/stackit/cdn/__init__.py index cb05eb30..ea029ae1 100644 --- a/services/cdn/src/stackit/cdn/__init__.py +++ b/services/cdn/src/stackit/cdn/__init__.py @@ -43,6 +43,7 @@ from stackit.cdn.models.delete_custom_domain_response import DeleteCustomDomainResponse from stackit.cdn.models.delete_distribution_response import DeleteDistributionResponse from stackit.cdn.models.distribution import Distribution +from stackit.cdn.models.distribution_logs_record import DistributionLogsRecord from stackit.cdn.models.distribution_statistics_record import ( DistributionStatisticsRecord, ) @@ -54,20 +55,19 @@ ) from stackit.cdn.models.domain import Domain from stackit.cdn.models.domain_status import DomainStatus +from stackit.cdn.models.error_details import ErrorDetails from stackit.cdn.models.find_cache_paths_response import FindCachePathsResponse from stackit.cdn.models.find_cache_paths_response_entry import ( FindCachePathsResponseEntry, ) from stackit.cdn.models.generic_json_response import GenericJSONResponse -from stackit.cdn.models.generic_json_response_details_inner import ( - GenericJSONResponseDetailsInner, -) from stackit.cdn.models.get_cache_info_response import GetCacheInfoResponse from stackit.cdn.models.get_cache_info_response_history_entry import ( GetCacheInfoResponseHistoryEntry, ) from stackit.cdn.models.get_custom_domain_response import GetCustomDomainResponse from stackit.cdn.models.get_distribution_response import GetDistributionResponse +from stackit.cdn.models.get_logs_response import GetLogsResponse from stackit.cdn.models.get_statistics_response import GetStatisticsResponse from stackit.cdn.models.http_backend import HttpBackend from stackit.cdn.models.http_backend_patch import HttpBackendPatch diff --git a/services/cdn/src/stackit/cdn/api/default_api.py b/services/cdn/src/stackit/cdn/api/default_api.py index 828455dd..98bcfcff 100644 --- a/services/cdn/src/stackit/cdn/api/default_api.py +++ b/services/cdn/src/stackit/cdn/api/default_api.py @@ -34,6 +34,7 @@ from stackit.cdn.models.get_cache_info_response import GetCacheInfoResponse from stackit.cdn.models.get_custom_domain_response import GetCustomDomainResponse from stackit.cdn.models.get_distribution_response import GetDistributionResponse +from stackit.cdn.models.get_logs_response import GetLogsResponse from stackit.cdn.models.get_statistics_response import GetStatisticsResponse from stackit.cdn.models.list_distributions_response import ListDistributionsResponse from stackit.cdn.models.patch_distribution_payload import PatchDistributionPayload @@ -60,7 +61,7 @@ def __init__(self, configuration: Configuration = None) -> None: @validate_call def create_distribution( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], create_distribution_payload: CreateDistributionPayload, _request_timeout: Union[ None, @@ -76,7 +77,7 @@ def create_distribution( CreateDistribution will create a new CDN distribution - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param create_distribution_payload: (required) :type create_distribution_payload: CreateDistributionPayload @@ -128,7 +129,7 @@ def create_distribution( @validate_call def create_distribution_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], create_distribution_payload: CreateDistributionPayload, _request_timeout: Union[ None, @@ -144,7 +145,7 @@ def create_distribution_with_http_info( CreateDistribution will create a new CDN distribution - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param create_distribution_payload: (required) :type create_distribution_payload: CreateDistributionPayload @@ -196,7 +197,7 @@ def create_distribution_with_http_info( @validate_call def create_distribution_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], create_distribution_payload: CreateDistributionPayload, _request_timeout: Union[ None, @@ -212,7 +213,7 @@ def create_distribution_without_preload_content( CreateDistribution will create a new CDN distribution - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param create_distribution_payload: (required) :type create_distribution_payload: CreateDistributionPayload @@ -321,7 +322,7 @@ def _create_distribution_serialize( @validate_call def delete_custom_domain( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], intent_id: Optional[StrictStr] = None, @@ -339,7 +340,7 @@ def delete_custom_domain( Removes a custom domain - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -396,7 +397,7 @@ def delete_custom_domain( @validate_call def delete_custom_domain_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], intent_id: Optional[StrictStr] = None, @@ -414,7 +415,7 @@ def delete_custom_domain_with_http_info( Removes a custom domain - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -471,7 +472,7 @@ def delete_custom_domain_with_http_info( @validate_call def delete_custom_domain_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], intent_id: Optional[StrictStr] = None, @@ -489,7 +490,7 @@ def delete_custom_domain_without_preload_content( Removes a custom domain - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -603,7 +604,7 @@ def _delete_custom_domain_serialize( @validate_call def delete_distribution( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, intent_id: Annotated[ Optional[StrictStr], @@ -625,7 +626,7 @@ def delete_distribution( DeleteDistribution accepts a project- and distribution-ID and will delete a distribution. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -679,7 +680,7 @@ def delete_distribution( @validate_call def delete_distribution_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, intent_id: Annotated[ Optional[StrictStr], @@ -701,7 +702,7 @@ def delete_distribution_with_http_info( DeleteDistribution accepts a project- and distribution-ID and will delete a distribution. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -755,7 +756,7 @@ def delete_distribution_with_http_info( @validate_call def delete_distribution_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, intent_id: Annotated[ Optional[StrictStr], @@ -777,7 +778,7 @@ def delete_distribution_without_preload_content( DeleteDistribution accepts a project- and distribution-ID and will delete a distribution. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -885,7 +886,7 @@ def _delete_distribution_serialize( @validate_call def find_cache_paths( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, path: Annotated[StrictStr, Field(description="A substring of the search query. ")], _request_timeout: Union[ @@ -902,7 +903,7 @@ def find_cache_paths( This returns paths that are present in the cache purging history. Only substrings of the provided input are returned. The response is sorted in descending order by the most recent purge. So, assuming you have have the following purged for a distribution - `/test/1` at `2025-01-01` - `/test/2` at `2025-01-02` - `/someOtherPath/1` at `2025-01-03` - `/test/1` at `2025-01-04` - `/test/3` at `2025-01-05`, this would return the following paths, in the following order, assuming `/te` was the search parameter: - `/test/3` - `/test/1` - `/test/2` - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -956,7 +957,7 @@ def find_cache_paths( @validate_call def find_cache_paths_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, path: Annotated[StrictStr, Field(description="A substring of the search query. ")], _request_timeout: Union[ @@ -973,7 +974,7 @@ def find_cache_paths_with_http_info( This returns paths that are present in the cache purging history. Only substrings of the provided input are returned. The response is sorted in descending order by the most recent purge. So, assuming you have have the following purged for a distribution - `/test/1` at `2025-01-01` - `/test/2` at `2025-01-02` - `/someOtherPath/1` at `2025-01-03` - `/test/1` at `2025-01-04` - `/test/3` at `2025-01-05`, this would return the following paths, in the following order, assuming `/te` was the search parameter: - `/test/3` - `/test/1` - `/test/2` - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1027,7 +1028,7 @@ def find_cache_paths_with_http_info( @validate_call def find_cache_paths_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, path: Annotated[StrictStr, Field(description="A substring of the search query. ")], _request_timeout: Union[ @@ -1044,7 +1045,7 @@ def find_cache_paths_without_preload_content( This returns paths that are present in the cache purging history. Only substrings of the provided input are returned. The response is sorted in descending order by the most recent purge. So, assuming you have have the following purged for a distribution - `/test/1` at `2025-01-01` - `/test/2` at `2025-01-02` - `/someOtherPath/1` at `2025-01-03` - `/test/1` at `2025-01-04` - `/test/3` at `2025-01-05`, this would return the following paths, in the following order, assuming `/te` was the search parameter: - `/test/3` - `/test/1` - `/test/2` - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1152,7 +1153,7 @@ def _find_cache_paths_serialize( @validate_call def get_cache_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, purge_path: Optional[StrictStr] = None, _request_timeout: Union[ @@ -1169,7 +1170,7 @@ def get_cache_info( Return caching info metadata, which contains the last cache purging time and a history of the most recent *full* purges. If (and only if) you provide the path query parameter, the history will also contain granular cache purges. The request will not fail if no data about a path is found. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1223,7 +1224,7 @@ def get_cache_info( @validate_call def get_cache_info_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, purge_path: Optional[StrictStr] = None, _request_timeout: Union[ @@ -1240,7 +1241,7 @@ def get_cache_info_with_http_info( Return caching info metadata, which contains the last cache purging time and a history of the most recent *full* purges. If (and only if) you provide the path query parameter, the history will also contain granular cache purges. The request will not fail if no data about a path is found. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1294,7 +1295,7 @@ def get_cache_info_with_http_info( @validate_call def get_cache_info_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, purge_path: Optional[StrictStr] = None, _request_timeout: Union[ @@ -1311,7 +1312,7 @@ def get_cache_info_without_preload_content( Return caching info metadata, which contains the last cache purging time and a history of the most recent *full* purges. If (and only if) you provide the path query parameter, the history will also contain granular cache purges. The request will not fail if no data about a path is found. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1419,7 +1420,7 @@ def _get_cache_info_serialize( @validate_call def get_custom_domain( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], _request_timeout: Union[ @@ -1436,7 +1437,7 @@ def get_custom_domain( Returns a 200 and the custom domain if this custom domain was associated to this distribution, else 404 - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1491,7 +1492,7 @@ def get_custom_domain( @validate_call def get_custom_domain_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], _request_timeout: Union[ @@ -1508,7 +1509,7 @@ def get_custom_domain_with_http_info( Returns a 200 and the custom domain if this custom domain was associated to this distribution, else 404 - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1563,7 +1564,7 @@ def get_custom_domain_with_http_info( @validate_call def get_custom_domain_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], _request_timeout: Union[ @@ -1580,7 +1581,7 @@ def get_custom_domain_without_preload_content( Returns a 200 and the custom domain if this custom domain was associated to this distribution, else 404 - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1687,7 +1688,7 @@ def _get_custom_domain_serialize( @validate_call def get_distribution( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, _request_timeout: Union[ None, @@ -1703,7 +1704,7 @@ def get_distribution( This returns a specific distribution by its ID. If no distribution with the given ID exists the endpoint returns 404. Trying to get a deleted distributions also return 404. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1755,7 +1756,7 @@ def get_distribution( @validate_call def get_distribution_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, _request_timeout: Union[ None, @@ -1771,7 +1772,7 @@ def get_distribution_with_http_info( This returns a specific distribution by its ID. If no distribution with the given ID exists the endpoint returns 404. Trying to get a deleted distributions also return 404. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1823,7 +1824,7 @@ def get_distribution_with_http_info( @validate_call def get_distribution_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, _request_timeout: Union[ None, @@ -1839,7 +1840,7 @@ def get_distribution_without_preload_content( This returns a specific distribution by its ID. If no distribution with the given ID exists the endpoint returns 404. Trying to get a deleted distributions also return 404. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -1937,10 +1938,429 @@ def _get_distribution_serialize( _request_auth=_request_auth, ) + @validate_call + def get_logs( + self, + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], + distribution_id: Annotated[StrictStr, Field(description="Your CDN distribution ID")], + var_from: Annotated[ + Optional[datetime], Field(description="the start of the time range for which logs should be returned") + ] = None, + to: Annotated[ + Optional[datetime], + Field( + description='the end of the time range for which logs should be returned. If not specified, "now" is used. ' + ), + ] = None, + page_size: Annotated[ + Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]], + Field( + description="Quantifies how many log entries should be returned on this page. Must be a natural number between 1 and 1000 (inclusive) " + ), + ] = None, + page_identifier: Annotated[ + Optional[StrictStr], + Field( + description='Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get "pushed" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. ' + ), + ] = None, + sort_by: Annotated[ + Optional[StrictStr], + Field( + description="The following sort options exist. We default to `timestamp` - `timestamp` - Sort by log message time stamp. " + ), + ] = None, + sort_order: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetLogsResponse: + """Retrieve distribution logs + + + :param project_id: Your STACKIT Project ID (required) + :type project_id: str + :param distribution_id: Your CDN distribution ID (required) + :type distribution_id: str + :param var_from: the start of the time range for which logs should be returned + :type var_from: datetime + :param to: the end of the time range for which logs should be returned. If not specified, \"now\" is used. + :type to: datetime + :param page_size: Quantifies how many log entries should be returned on this page. Must be a natural number between 1 and 1000 (inclusive) + :type page_size: int + :param page_identifier: Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get \"pushed\" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. + :type page_identifier: str + :param sort_by: The following sort options exist. We default to `timestamp` - `timestamp` - Sort by log message time stamp. + :type sort_by: str + :param sort_order: + :type sort_order: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_logs_serialize( + project_id=project_id, + distribution_id=distribution_id, + var_from=var_from, + to=to, + page_size=page_size, + page_identifier=page_identifier, + sort_by=sort_by, + sort_order=sort_order, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogsResponse", + "401": "str", + "422": "GenericJSONResponse", + "500": "GenericJSONResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_logs_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], + distribution_id: Annotated[StrictStr, Field(description="Your CDN distribution ID")], + var_from: Annotated[ + Optional[datetime], Field(description="the start of the time range for which logs should be returned") + ] = None, + to: Annotated[ + Optional[datetime], + Field( + description='the end of the time range for which logs should be returned. If not specified, "now" is used. ' + ), + ] = None, + page_size: Annotated[ + Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]], + Field( + description="Quantifies how many log entries should be returned on this page. Must be a natural number between 1 and 1000 (inclusive) " + ), + ] = None, + page_identifier: Annotated[ + Optional[StrictStr], + Field( + description='Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get "pushed" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. ' + ), + ] = None, + sort_by: Annotated[ + Optional[StrictStr], + Field( + description="The following sort options exist. We default to `timestamp` - `timestamp` - Sort by log message time stamp. " + ), + ] = None, + sort_order: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetLogsResponse]: + """Retrieve distribution logs + + + :param project_id: Your STACKIT Project ID (required) + :type project_id: str + :param distribution_id: Your CDN distribution ID (required) + :type distribution_id: str + :param var_from: the start of the time range for which logs should be returned + :type var_from: datetime + :param to: the end of the time range for which logs should be returned. If not specified, \"now\" is used. + :type to: datetime + :param page_size: Quantifies how many log entries should be returned on this page. Must be a natural number between 1 and 1000 (inclusive) + :type page_size: int + :param page_identifier: Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get \"pushed\" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. + :type page_identifier: str + :param sort_by: The following sort options exist. We default to `timestamp` - `timestamp` - Sort by log message time stamp. + :type sort_by: str + :param sort_order: + :type sort_order: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_logs_serialize( + project_id=project_id, + distribution_id=distribution_id, + var_from=var_from, + to=to, + page_size=page_size, + page_identifier=page_identifier, + sort_by=sort_by, + sort_order=sort_order, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogsResponse", + "401": "str", + "422": "GenericJSONResponse", + "500": "GenericJSONResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_logs_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], + distribution_id: Annotated[StrictStr, Field(description="Your CDN distribution ID")], + var_from: Annotated[ + Optional[datetime], Field(description="the start of the time range for which logs should be returned") + ] = None, + to: Annotated[ + Optional[datetime], + Field( + description='the end of the time range for which logs should be returned. If not specified, "now" is used. ' + ), + ] = None, + page_size: Annotated[ + Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]], + Field( + description="Quantifies how many log entries should be returned on this page. Must be a natural number between 1 and 1000 (inclusive) " + ), + ] = None, + page_identifier: Annotated[ + Optional[StrictStr], + Field( + description='Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get "pushed" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. ' + ), + ] = None, + sort_by: Annotated[ + Optional[StrictStr], + Field( + description="The following sort options exist. We default to `timestamp` - `timestamp` - Sort by log message time stamp. " + ), + ] = None, + sort_order: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Retrieve distribution logs + + + :param project_id: Your STACKIT Project ID (required) + :type project_id: str + :param distribution_id: Your CDN distribution ID (required) + :type distribution_id: str + :param var_from: the start of the time range for which logs should be returned + :type var_from: datetime + :param to: the end of the time range for which logs should be returned. If not specified, \"now\" is used. + :type to: datetime + :param page_size: Quantifies how many log entries should be returned on this page. Must be a natural number between 1 and 1000 (inclusive) + :type page_size: int + :param page_identifier: Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get \"pushed\" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. + :type page_identifier: str + :param sort_by: The following sort options exist. We default to `timestamp` - `timestamp` - Sort by log message time stamp. + :type sort_by: str + :param sort_order: + :type sort_order: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_logs_serialize( + project_id=project_id, + distribution_id=distribution_id, + var_from=var_from, + to=to, + page_size=page_size, + page_identifier=page_identifier, + sort_by=sort_by, + sort_order=sort_order, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetLogsResponse", + "401": "str", + "422": "GenericJSONResponse", + "500": "GenericJSONResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_logs_serialize( + self, + project_id, + distribution_id, + var_from, + to, + page_size, + page_identifier, + sort_by, + sort_order, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if distribution_id is not None: + _path_params["distributionId"] = distribution_id + # process the query parameters + if var_from is not None: + if isinstance(var_from, datetime): + _query_params.append(("from", var_from.strftime(self.api_client.configuration.datetime_format))) + else: + _query_params.append(("from", var_from)) + + if to is not None: + if isinstance(to, datetime): + _query_params.append(("to", to.strftime(self.api_client.configuration.datetime_format))) + else: + _query_params.append(("to", to)) + + if page_size is not None: + + _query_params.append(("pageSize", page_size)) + + if page_identifier is not None: + + _query_params.append(("pageIdentifier", page_identifier)) + + if sort_by is not None: + + _query_params.append(("sortBy", sort_by)) + + if sort_order is not None: + + _query_params.append(("sortOrder", sort_order)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json", "text/plain"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/distributions/{distributionId}/logs", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + @validate_call def get_statistics( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, var_from: Annotated[ datetime, Field(description="the start of the time range for which statistics should be returned") @@ -1948,7 +2368,7 @@ def get_statistics( to: Annotated[ Optional[datetime], Field( - description="the end of the time range for which statistics should be returned. If not specified, the end of the current time's interval is used, e.g. next day for daily, next month for monthly, and so on. " + description="the end of the time range for which statistics should be returned. If not specified, the end of the current time interval is used, e.g. next day for daily, next month for monthly, and so on. " ), ] = None, interval: Annotated[ @@ -1971,13 +2391,13 @@ def get_statistics( Returns the statistics of the distribution in the given time range. The response is a list of statistics records. Each record aggregates the statistics for its time interval. In case no statistics for a time interval exist, no record is returned. The time range for which statistics should be returned can be configured using query parameters. Timestamps are assumed to be UTC. This is especially important for the \"buckets\" when you, for example, return daily information. A day always starts and ends at 00:00Z. **Important Note:** Lower bounds are inclusive, upper bounds are exclusive. If you, for example, want a daily grouped which starts on the 1st Jan and also contains the full 10th Jan day, you would define `2025-01-01T00:00:00Z` as the lower and `2025-01-11T00:00:00Z` as the upper bound. The upper bound is optional. If you omit it, the API will use the start of the next interval as the upper bound. Example: if `interval` is `hourly`, `from` would default to the start of the next hour, if it's `daily`, `from` would default to the start of the next day, etc. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str :param var_from: the start of the time range for which statistics should be returned (required) :type var_from: datetime - :param to: the end of the time range for which statistics should be returned. If not specified, the end of the current time's interval is used, e.g. next day for daily, next month for monthly, and so on. + :param to: the end of the time range for which statistics should be returned. If not specified, the end of the current time interval is used, e.g. next day for daily, next month for monthly, and so on. :type to: datetime :param interval: Over which interval should statistics be aggregated? defaults to hourly resolution **NOTE**: Intervals are grouped in buckets that start and end based on a day in UTC+0 time. So for the `daily` interval, the group starts (inclusive) and ends (exclusive) at `00:00Z` :type interval: str @@ -2031,7 +2451,7 @@ def get_statistics( @validate_call def get_statistics_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, var_from: Annotated[ datetime, Field(description="the start of the time range for which statistics should be returned") @@ -2039,7 +2459,7 @@ def get_statistics_with_http_info( to: Annotated[ Optional[datetime], Field( - description="the end of the time range for which statistics should be returned. If not specified, the end of the current time's interval is used, e.g. next day for daily, next month for monthly, and so on. " + description="the end of the time range for which statistics should be returned. If not specified, the end of the current time interval is used, e.g. next day for daily, next month for monthly, and so on. " ), ] = None, interval: Annotated[ @@ -2062,13 +2482,13 @@ def get_statistics_with_http_info( Returns the statistics of the distribution in the given time range. The response is a list of statistics records. Each record aggregates the statistics for its time interval. In case no statistics for a time interval exist, no record is returned. The time range for which statistics should be returned can be configured using query parameters. Timestamps are assumed to be UTC. This is especially important for the \"buckets\" when you, for example, return daily information. A day always starts and ends at 00:00Z. **Important Note:** Lower bounds are inclusive, upper bounds are exclusive. If you, for example, want a daily grouped which starts on the 1st Jan and also contains the full 10th Jan day, you would define `2025-01-01T00:00:00Z` as the lower and `2025-01-11T00:00:00Z` as the upper bound. The upper bound is optional. If you omit it, the API will use the start of the next interval as the upper bound. Example: if `interval` is `hourly`, `from` would default to the start of the next hour, if it's `daily`, `from` would default to the start of the next day, etc. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str :param var_from: the start of the time range for which statistics should be returned (required) :type var_from: datetime - :param to: the end of the time range for which statistics should be returned. If not specified, the end of the current time's interval is used, e.g. next day for daily, next month for monthly, and so on. + :param to: the end of the time range for which statistics should be returned. If not specified, the end of the current time interval is used, e.g. next day for daily, next month for monthly, and so on. :type to: datetime :param interval: Over which interval should statistics be aggregated? defaults to hourly resolution **NOTE**: Intervals are grouped in buckets that start and end based on a day in UTC+0 time. So for the `daily` interval, the group starts (inclusive) and ends (exclusive) at `00:00Z` :type interval: str @@ -2122,7 +2542,7 @@ def get_statistics_with_http_info( @validate_call def get_statistics_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, var_from: Annotated[ datetime, Field(description="the start of the time range for which statistics should be returned") @@ -2130,7 +2550,7 @@ def get_statistics_without_preload_content( to: Annotated[ Optional[datetime], Field( - description="the end of the time range for which statistics should be returned. If not specified, the end of the current time's interval is used, e.g. next day for daily, next month for monthly, and so on. " + description="the end of the time range for which statistics should be returned. If not specified, the end of the current time interval is used, e.g. next day for daily, next month for monthly, and so on. " ), ] = None, interval: Annotated[ @@ -2153,13 +2573,13 @@ def get_statistics_without_preload_content( Returns the statistics of the distribution in the given time range. The response is a list of statistics records. Each record aggregates the statistics for its time interval. In case no statistics for a time interval exist, no record is returned. The time range for which statistics should be returned can be configured using query parameters. Timestamps are assumed to be UTC. This is especially important for the \"buckets\" when you, for example, return daily information. A day always starts and ends at 00:00Z. **Important Note:** Lower bounds are inclusive, upper bounds are exclusive. If you, for example, want a daily grouped which starts on the 1st Jan and also contains the full 10th Jan day, you would define `2025-01-01T00:00:00Z` as the lower and `2025-01-11T00:00:00Z` as the upper bound. The upper bound is optional. If you omit it, the API will use the start of the next interval as the upper bound. Example: if `interval` is `hourly`, `from` would default to the start of the next hour, if it's `daily`, `from` would default to the start of the next day, etc. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str :param var_from: the start of the time range for which statistics should be returned (required) :type var_from: datetime - :param to: the end of the time range for which statistics should be returned. If not specified, the end of the current time's interval is used, e.g. next day for daily, next month for monthly, and so on. + :param to: the end of the time range for which statistics should be returned. If not specified, the end of the current time interval is used, e.g. next day for daily, next month for monthly, and so on. :type to: datetime :param interval: Over which interval should statistics be aggregated? defaults to hourly resolution **NOTE**: Intervals are grouped in buckets that start and end based on a day in UTC+0 time. So for the `daily` interval, the group starts (inclusive) and ends (exclusive) at `00:00Z` :type interval: str @@ -2281,7 +2701,7 @@ def _get_statistics_serialize( @validate_call def list_distributions( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], page_size: Annotated[ Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field( @@ -2297,7 +2717,7 @@ def list_distributions( sort_by: Annotated[ Optional[StrictStr], Field( - description="The following sort options exist. We default to `createdAt` - `id` - Sort by the distributions's ID using String comparison - `updatedAt` - Sort by when the distribution's configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by looking at the distribution's status, using String comparison " + description="The following sort options exist. We default to `createdAt` - `id` - Sort by distribution ID using String comparison - `updatedAt` - Sort by when the distribution configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by distribution status, using String comparison " ), ] = None, sort_order: Optional[StrictStr] = None, @@ -2315,13 +2735,13 @@ def list_distributions( ListDistributions returns a list of all CDN distributions associated with a given project, ordered by their distribution ID. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param page_size: Quantifies how many distributions should be returned on this page. Must be a natural number between 1 and 100 (inclusive) :type page_size: int :param page_identifier: Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get \"pushed\" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. :type page_identifier: str - :param sort_by: The following sort options exist. We default to `createdAt` - `id` - Sort by the distributions's ID using String comparison - `updatedAt` - Sort by when the distribution's configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by looking at the distribution's status, using String comparison + :param sort_by: The following sort options exist. We default to `createdAt` - `id` - Sort by distribution ID using String comparison - `updatedAt` - Sort by when the distribution configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by distribution status, using String comparison :type sort_by: str :param sort_order: :type sort_order: str @@ -2375,7 +2795,7 @@ def list_distributions( @validate_call def list_distributions_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], page_size: Annotated[ Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field( @@ -2391,7 +2811,7 @@ def list_distributions_with_http_info( sort_by: Annotated[ Optional[StrictStr], Field( - description="The following sort options exist. We default to `createdAt` - `id` - Sort by the distributions's ID using String comparison - `updatedAt` - Sort by when the distribution's configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by looking at the distribution's status, using String comparison " + description="The following sort options exist. We default to `createdAt` - `id` - Sort by distribution ID using String comparison - `updatedAt` - Sort by when the distribution configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by distribution status, using String comparison " ), ] = None, sort_order: Optional[StrictStr] = None, @@ -2409,13 +2829,13 @@ def list_distributions_with_http_info( ListDistributions returns a list of all CDN distributions associated with a given project, ordered by their distribution ID. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param page_size: Quantifies how many distributions should be returned on this page. Must be a natural number between 1 and 100 (inclusive) :type page_size: int :param page_identifier: Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get \"pushed\" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. :type page_identifier: str - :param sort_by: The following sort options exist. We default to `createdAt` - `id` - Sort by the distributions's ID using String comparison - `updatedAt` - Sort by when the distribution's configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by looking at the distribution's status, using String comparison + :param sort_by: The following sort options exist. We default to `createdAt` - `id` - Sort by distribution ID using String comparison - `updatedAt` - Sort by when the distribution configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by distribution status, using String comparison :type sort_by: str :param sort_order: :type sort_order: str @@ -2469,7 +2889,7 @@ def list_distributions_with_http_info( @validate_call def list_distributions_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], page_size: Annotated[ Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field( @@ -2485,7 +2905,7 @@ def list_distributions_without_preload_content( sort_by: Annotated[ Optional[StrictStr], Field( - description="The following sort options exist. We default to `createdAt` - `id` - Sort by the distributions's ID using String comparison - `updatedAt` - Sort by when the distribution's configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by looking at the distribution's status, using String comparison " + description="The following sort options exist. We default to `createdAt` - `id` - Sort by distribution ID using String comparison - `updatedAt` - Sort by when the distribution configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by distribution status, using String comparison " ), ] = None, sort_order: Optional[StrictStr] = None, @@ -2503,13 +2923,13 @@ def list_distributions_without_preload_content( ListDistributions returns a list of all CDN distributions associated with a given project, ordered by their distribution ID. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param page_size: Quantifies how many distributions should be returned on this page. Must be a natural number between 1 and 100 (inclusive) :type page_size: int :param page_identifier: Identifier is returned by the previous response and is used to request the next page. As the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result. So a scenario like: - Start listing first page - Insert new element - Start listing second page will *never* result in an element from the first page to get \"pushed\" to the second page, like it could occur with basic limit + offset pagination. The identifier should be treated as an opaque string and never modified. Only pass values returned by the API. :type page_identifier: str - :param sort_by: The following sort options exist. We default to `createdAt` - `id` - Sort by the distributions's ID using String comparison - `updatedAt` - Sort by when the distribution's configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by looking at the distribution's status, using String comparison + :param sort_by: The following sort options exist. We default to `createdAt` - `id` - Sort by distribution ID using String comparison - `updatedAt` - Sort by when the distribution configuration was last modified, for example by changing the regions or response headers - `createdAt` - Sort by when the distribution was initially created. - `originUrl` - Sort by originURL using String comparison - `status` - Sort by distribution status, using String comparison :type sort_by: str :param sort_order: :type sort_order: str @@ -2629,7 +3049,7 @@ def _list_distributions_serialize( @validate_call def patch_distribution( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, patch_distribution_payload: Optional[PatchDistributionPayload] = None, _request_timeout: Union[ @@ -2646,7 +3066,7 @@ def patch_distribution( Modify a CDN distribution with a partial update. Only the fields specified in the request will be modified. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -2700,7 +3120,7 @@ def patch_distribution( @validate_call def patch_distribution_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, patch_distribution_payload: Optional[PatchDistributionPayload] = None, _request_timeout: Union[ @@ -2717,7 +3137,7 @@ def patch_distribution_with_http_info( Modify a CDN distribution with a partial update. Only the fields specified in the request will be modified. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -2771,7 +3191,7 @@ def patch_distribution_with_http_info( @validate_call def patch_distribution_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, patch_distribution_payload: Optional[PatchDistributionPayload] = None, _request_timeout: Union[ @@ -2788,7 +3208,7 @@ def patch_distribution_without_preload_content( Modify a CDN distribution with a partial update. Only the fields specified in the request will be modified. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -2902,7 +3322,7 @@ def _patch_distribution_serialize( @validate_call def purge_cache( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, purge_cache_payload: Optional[PurgeCachePayload] = None, _request_timeout: Union[ @@ -2915,11 +3335,11 @@ def purge_cache( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> object: - """Clear distribution's cache + """Clear distribution cache Clear the cache for this distribution. All content, regardless of its staleness, will get refetched from the host. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -2973,7 +3393,7 @@ def purge_cache( @validate_call def purge_cache_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, purge_cache_payload: Optional[PurgeCachePayload] = None, _request_timeout: Union[ @@ -2986,11 +3406,11 @@ def purge_cache_with_http_info( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[object]: - """Clear distribution's cache + """Clear distribution cache Clear the cache for this distribution. All content, regardless of its staleness, will get refetched from the host. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -3044,7 +3464,7 @@ def purge_cache_with_http_info( @validate_call def purge_cache_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, purge_cache_payload: Optional[PurgeCachePayload] = None, _request_timeout: Union[ @@ -3057,11 +3477,11 @@ def purge_cache_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Clear distribution's cache + """Clear distribution cache Clear the cache for this distribution. All content, regardless of its staleness, will get refetched from the host. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -3175,7 +3595,7 @@ def _purge_cache_serialize( @validate_call def put_custom_domain( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], put_custom_domain_payload: Optional[PutCustomDomainPayload] = None, @@ -3193,7 +3613,7 @@ def put_custom_domain( Creates a new custom domain. If it already exists, this will overwrite the previous custom domain's properties. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -3250,7 +3670,7 @@ def put_custom_domain( @validate_call def put_custom_domain_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], put_custom_domain_payload: Optional[PutCustomDomainPayload] = None, @@ -3268,7 +3688,7 @@ def put_custom_domain_with_http_info( Creates a new custom domain. If it already exists, this will overwrite the previous custom domain's properties. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str @@ -3325,7 +3745,7 @@ def put_custom_domain_with_http_info( @validate_call def put_custom_domain_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="Your STACKIT Project's ID")], + project_id: Annotated[StrictStr, Field(description="Your STACKIT Project ID")], distribution_id: StrictStr, domain: Annotated[str, Field(strict=True, max_length=72)], put_custom_domain_payload: Optional[PutCustomDomainPayload] = None, @@ -3343,7 +3763,7 @@ def put_custom_domain_without_preload_content( Creates a new custom domain. If it already exists, this will overwrite the previous custom domain's properties. - :param project_id: Your STACKIT Project's ID (required) + :param project_id: Your STACKIT Project ID (required) :type project_id: str :param distribution_id: (required) :type distribution_id: str diff --git a/services/cdn/src/stackit/cdn/models/__init__.py b/services/cdn/src/stackit/cdn/models/__init__.py index a7d2a072..a02eeb05 100644 --- a/services/cdn/src/stackit/cdn/models/__init__.py +++ b/services/cdn/src/stackit/cdn/models/__init__.py @@ -24,6 +24,7 @@ from stackit.cdn.models.delete_custom_domain_response import DeleteCustomDomainResponse from stackit.cdn.models.delete_distribution_response import DeleteDistributionResponse from stackit.cdn.models.distribution import Distribution +from stackit.cdn.models.distribution_logs_record import DistributionLogsRecord from stackit.cdn.models.distribution_statistics_record import ( DistributionStatisticsRecord, ) @@ -35,20 +36,19 @@ ) from stackit.cdn.models.domain import Domain from stackit.cdn.models.domain_status import DomainStatus +from stackit.cdn.models.error_details import ErrorDetails from stackit.cdn.models.find_cache_paths_response import FindCachePathsResponse from stackit.cdn.models.find_cache_paths_response_entry import ( FindCachePathsResponseEntry, ) from stackit.cdn.models.generic_json_response import GenericJSONResponse -from stackit.cdn.models.generic_json_response_details_inner import ( - GenericJSONResponseDetailsInner, -) from stackit.cdn.models.get_cache_info_response import GetCacheInfoResponse from stackit.cdn.models.get_cache_info_response_history_entry import ( GetCacheInfoResponseHistoryEntry, ) from stackit.cdn.models.get_custom_domain_response import GetCustomDomainResponse from stackit.cdn.models.get_distribution_response import GetDistributionResponse +from stackit.cdn.models.get_logs_response import GetLogsResponse from stackit.cdn.models.get_statistics_response import GetStatisticsResponse from stackit.cdn.models.http_backend import HttpBackend from stackit.cdn.models.http_backend_patch import HttpBackendPatch diff --git a/services/cdn/src/stackit/cdn/models/config.py b/services/cdn/src/stackit/cdn/models/config.py index e6a8cb3c..369b796d 100644 --- a/services/cdn/src/stackit/cdn/models/config.py +++ b/services/cdn/src/stackit/cdn/models/config.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field +from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing_extensions import Annotated, Self from stackit.cdn.models.config_backend import ConfigBackend @@ -30,8 +30,21 @@ class Config(BaseModel): """ backend: ConfigBackend + blocked_countries: List[StrictStr] = Field( + description="Restricts access to your content based on country. We use the ISO 3166-1 alpha-2 standard for country codes (e.g., DE, ES, GB). This setting blocks users from the specified countries. ", + alias="blockedCountries", + ) + blocked_ips: List[StrictStr] = Field( + description="Restricts access to your content by specifying a list of blocked IPv4 addresses. This feature enhances security and privacy by preventing these addresses from accessing your distribution. ", + alias="blockedIPs", + ) + monthly_limit_bytes: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( + default=None, + description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ", + alias="monthlyLimitBytes", + ) regions: Annotated[List[Region], Field(min_length=1)] - __properties: ClassVar[List[str]] = ["backend", "regions"] + __properties: ClassVar[List[str]] = ["backend", "blockedCountries", "blockedIPs", "monthlyLimitBytes", "regions"] model_config = ConfigDict( populate_by_name=True, @@ -73,6 +86,11 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of backend if self.backend: _dict["backend"] = self.backend.to_dict() + # set to None if monthly_limit_bytes (nullable) is None + # and model_fields_set contains the field + if self.monthly_limit_bytes is None and "monthly_limit_bytes" in self.model_fields_set: + _dict["monthlyLimitBytes"] = None + return _dict @classmethod @@ -87,6 +105,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { "backend": ConfigBackend.from_dict(obj["backend"]) if obj.get("backend") is not None else None, + "blockedCountries": obj.get("blockedCountries"), + "blockedIPs": obj.get("blockedIPs"), + "monthlyLimitBytes": obj.get("monthlyLimitBytes"), "regions": obj.get("regions"), } ) diff --git a/services/cdn/src/stackit/cdn/models/config_patch.py b/services/cdn/src/stackit/cdn/models/config_patch.py index 18a7edaf..e3da5bde 100644 --- a/services/cdn/src/stackit/cdn/models/config_patch.py +++ b/services/cdn/src/stackit/cdn/models/config_patch.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field +from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing_extensions import Annotated, Self from stackit.cdn.models.config_patch_backend import ConfigPatchBackend @@ -30,8 +30,23 @@ class ConfigPatch(BaseModel): """ backend: Optional[ConfigPatchBackend] = None + blocked_countries: Optional[List[StrictStr]] = Field( + default=None, + description="Restricts access to your content based on country. We use the ISO 3166-1 alpha-2 standard for country codes (e.g., DE, ES, GB). This setting blocks users from the specified countries. ", + alias="blockedCountries", + ) + blocked_ips: Optional[List[StrictStr]] = Field( + default=None, + description="Restricts access to your content by specifying a list of blocked IPv4 addresses. This feature enhances security and privacy by preventing these addresses from accessing your distribution. ", + alias="blockedIPs", + ) + monthly_limit_bytes: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( + default=None, + description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ", + alias="monthlyLimitBytes", + ) regions: Optional[Annotated[List[Region], Field(min_length=1)]] = None - __properties: ClassVar[List[str]] = ["backend", "regions"] + __properties: ClassVar[List[str]] = ["backend", "blockedCountries", "blockedIPs", "monthlyLimitBytes", "regions"] model_config = ConfigDict( populate_by_name=True, @@ -73,6 +88,11 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of backend if self.backend: _dict["backend"] = self.backend.to_dict() + # set to None if monthly_limit_bytes (nullable) is None + # and model_fields_set contains the field + if self.monthly_limit_bytes is None and "monthly_limit_bytes" in self.model_fields_set: + _dict["monthlyLimitBytes"] = None + return _dict @classmethod @@ -87,6 +107,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { "backend": ConfigPatchBackend.from_dict(obj["backend"]) if obj.get("backend") is not None else None, + "blockedCountries": obj.get("blockedCountries"), + "blockedIPs": obj.get("blockedIPs"), + "monthlyLimitBytes": obj.get("monthlyLimitBytes"), "regions": obj.get("regions"), } ) diff --git a/services/cdn/src/stackit/cdn/models/create_distribution_payload.py b/services/cdn/src/stackit/cdn/models/create_distribution_payload.py index cceb1cb1..8fe8df57 100644 --- a/services/cdn/src/stackit/cdn/models/create_distribution_payload.py +++ b/services/cdn/src/stackit/cdn/models/create_distribution_payload.py @@ -28,11 +28,26 @@ class CreateDistributionPayload(BaseModel): CreateDistributionPayload """ + blocked_countries: Optional[List[StrictStr]] = Field( + default=None, + description="Restricts access to your content based on country. We use the ISO 3166-1 alpha-2 standard for country codes (e.g., DE, ES, GB). This setting blocks users from the specified countries. ", + alias="blockedCountries", + ) + blocked_ips: Optional[List[StrictStr]] = Field( + default=None, + description="Restricts access to your content by specifying a list of blocked IPv4 addresses. This feature enhances security and privacy by preventing these addresses from accessing your distribution. ", + alias="blockedIPs", + ) intent_id: Optional[StrictStr] = Field( default=None, description="While optional, it is greatly encouraged to provide an `intentId`. This is used to deduplicate requests. If multiple POST-Requests with the same `intentId` for a given `projectId` are received, all but the first request are dropped. ", alias="intentId", ) + monthly_limit_bytes: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( + default=None, + description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ", + alias="monthlyLimitBytes", + ) origin_request_headers: Optional[Dict[str, StrictStr]] = Field( default=None, description="Headers that will be sent with every request to the configured origin. WARNING: Do not store sensitive values in the headers. The data is stores as plain text. ", @@ -45,7 +60,15 @@ class CreateDistributionPayload(BaseModel): regions: Annotated[List[Region], Field(min_length=1)] = Field( description="Define in which regions you would like your content to be cached. " ) - __properties: ClassVar[List[str]] = ["intentId", "originRequestHeaders", "originUrl", "regions"] + __properties: ClassVar[List[str]] = [ + "blockedCountries", + "blockedIPs", + "intentId", + "monthlyLimitBytes", + "originRequestHeaders", + "originUrl", + "regions", + ] model_config = ConfigDict( populate_by_name=True, @@ -97,7 +120,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "blockedCountries": obj.get("blockedCountries"), + "blockedIPs": obj.get("blockedIPs"), "intentId": obj.get("intentId"), + "monthlyLimitBytes": obj.get("monthlyLimitBytes"), "originRequestHeaders": obj.get("originRequestHeaders"), "originUrl": obj.get("originUrl"), "regions": obj.get("regions"), diff --git a/services/cdn/src/stackit/cdn/models/distribution.py b/services/cdn/src/stackit/cdn/models/distribution.py index 92de388d..be6d41d8 100644 --- a/services/cdn/src/stackit/cdn/models/distribution.py +++ b/services/cdn/src/stackit/cdn/models/distribution.py @@ -46,7 +46,7 @@ class Distribution(BaseModel): description="- `CREATING`: The distribution was just created. All the relevant resources are created in the background. Once fully reconciled, this switches to `ACTIVE`. If there are any issues, the status changes to `ERROR`. You can look at the `errors` array to get more infos. - `ACTIVE`: The usual state. The desired configuration is synced, there are no errors - `UPDATING`: The state when there is a discrepancy between the desired and actual configuration state. This occurs right after an update. Will switch to `ACTIVE` or `ERROR`, depending on if synchronizing succeeds or not. - `DELETING`: The state right after a delete request was received. The distribution will stay in this status until all resources have been successfully removed, or until we encounter an `ERROR` state. **NOTE:** You can keep fetching the distribution while it is deleting. After successful deletion, trying to get a distribution will return a 404 Not Found response - `ERROR`: The error state. Look at the `errors` array for more info. " ) updated_at: datetime = Field( - description="RFC3339 string which returns the last time the distribution's configuration was modified. ", + description="RFC3339 string which returns the last time the distribution configuration was modified. ", alias="updatedAt", ) __properties: ClassVar[List[str]] = [ diff --git a/services/cdn/src/stackit/cdn/models/distribution_logs_record.py b/services/cdn/src/stackit/cdn/models/distribution_logs_record.py new file mode 100644 index 00000000..590bc99c --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/distribution_logs_record.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + CDN API + + API used to create and manage your CDN distributions. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from typing_extensions import Annotated, Self + + +class DistributionLogsRecord(BaseModel): + """ + DistributionLogsRecord + """ + + cache_hit: StrictBool = Field(alias="cacheHit") + data_center_region: StrictStr = Field(alias="dataCenterRegion") + distribution_id: StrictStr = Field(alias="distributionID") + host: StrictStr + path: StrictStr + request_country_code: Annotated[str, Field(min_length=2, strict=True, max_length=2)] = Field( + description="ISO 3166-1 A2 compliant country code", alias="requestCountryCode" + ) + size: Annotated[int, Field(strict=True, ge=0)] + status_code: StrictInt = Field(alias="statusCode") + timestamp: datetime + __properties: ClassVar[List[str]] = [ + "cacheHit", + "dataCenterRegion", + "distributionID", + "host", + "path", + "requestCountryCode", + "size", + "statusCode", + "timestamp", + ] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DistributionLogsRecord from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DistributionLogsRecord from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "cacheHit": obj.get("cacheHit"), + "dataCenterRegion": obj.get("dataCenterRegion"), + "distributionID": obj.get("distributionID"), + "host": obj.get("host"), + "path": obj.get("path"), + "requestCountryCode": obj.get("requestCountryCode"), + "size": obj.get("size"), + "statusCode": obj.get("statusCode"), + "timestamp": obj.get("timestamp"), + } + ) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/error_details.py b/services/cdn/src/stackit/cdn/models/error_details.py new file mode 100644 index 00000000..21a41100 --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/error_details.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + CDN API + + API used to create and manage your CDN distributions. + + The version of the OpenAPI document: 1beta.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, field_validator +from typing_extensions import Annotated, Self + + +class ErrorDetails(BaseModel): + """ + ErrorDetails + """ + + de: Optional[Annotated[str, Field(min_length=1, strict=True)]] = Field( + default=None, description="German description of the error" + ) + description: Annotated[str, Field(min_length=1, strict=True)] + en: Annotated[str, Field(min_length=1, strict=True)] = Field(description="English description of the error") + var_field: Optional[Annotated[str, Field(min_length=1, strict=True)]] = Field( + default=None, description="Optional field in the request this error detail refers to", alias="field" + ) + key: Annotated[str, Field(min_length=1, strict=True)] + __properties: ClassVar[List[str]] = ["de", "description", "en", "field", "key"] + + @field_validator("key") + def key_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["UNKNOWN", "CUSTOM_DOMAIN_CNAME_MISSING", "INVALID_ARGUMENT"]): + raise ValueError( + "must be one of enum values ('UNKNOWN', 'CUSTOM_DOMAIN_CNAME_MISSING', 'INVALID_ARGUMENT')" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ErrorDetails from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ErrorDetails from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "de": obj.get("de"), + "description": obj.get("description"), + "en": obj.get("en"), + "field": obj.get("field"), + "key": obj.get("key"), + } + ) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/generic_json_response.py b/services/cdn/src/stackit/cdn/models/generic_json_response.py index 118a3520..69e58e0c 100644 --- a/services/cdn/src/stackit/cdn/models/generic_json_response.py +++ b/services/cdn/src/stackit/cdn/models/generic_json_response.py @@ -20,9 +20,7 @@ from pydantic import BaseModel, ConfigDict, Field from typing_extensions import Annotated, Self -from stackit.cdn.models.generic_json_response_details_inner import ( - GenericJSONResponseDetailsInner, -) +from stackit.cdn.models.error_details import ErrorDetails class GenericJSONResponse(BaseModel): @@ -30,9 +28,7 @@ class GenericJSONResponse(BaseModel): GenericJSONResponse """ - details: Optional[List[GenericJSONResponseDetailsInner]] = Field( - default=None, description="Listing of issues with your request" - ) + details: Optional[List[ErrorDetails]] = Field(default=None, description="Listing of issues with your request") message: Annotated[str, Field(min_length=1, strict=True)] __properties: ClassVar[List[str]] = ["details", "message"] @@ -94,7 +90,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { "details": ( - [GenericJSONResponseDetailsInner.from_dict(_item) for _item in obj["details"]] + [ErrorDetails.from_dict(_item) for _item in obj["details"]] if obj.get("details") is not None else None ), diff --git a/services/cdn/src/stackit/cdn/models/generic_json_response_details_inner.py b/services/cdn/src/stackit/cdn/models/get_logs_response.py similarity index 61% rename from services/cdn/src/stackit/cdn/models/generic_json_response_details_inner.py rename to services/cdn/src/stackit/cdn/models/get_logs_response.py index bc1901f7..f48372cf 100644 --- a/services/cdn/src/stackit/cdn/models/generic_json_response_details_inner.py +++ b/services/cdn/src/stackit/cdn/models/get_logs_response.py @@ -17,18 +17,20 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field -from typing_extensions import Annotated, Self +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self +from stackit.cdn.models.distribution_logs_record import DistributionLogsRecord -class GenericJSONResponseDetailsInner(BaseModel): + +class GetLogsResponse(BaseModel): """ - GenericJSONResponseDetailsInner + GetLogsResponse """ - description: Annotated[str, Field(min_length=1, strict=True)] - var_field: Annotated[str, Field(min_length=1, strict=True)] = Field(alias="field") - __properties: ClassVar[List[str]] = ["description", "field"] + logs: List[DistributionLogsRecord] + next_page_identifier: Optional[StrictStr] = Field(default=None, alias="nextPageIdentifier") + __properties: ClassVar[List[str]] = ["logs", "nextPageIdentifier"] model_config = ConfigDict( populate_by_name=True, @@ -47,7 +49,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of GenericJSONResponseDetailsInner from a JSON string""" + """Create an instance of GetLogsResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -67,16 +69,32 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each item in logs (list) + _items = [] + if self.logs: + for _item in self.logs: + if _item: + _items.append(_item.to_dict()) + _dict["logs"] = _items return _dict @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of GenericJSONResponseDetailsInner from a dict""" + """Create an instance of GetLogsResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({"description": obj.get("description"), "field": obj.get("field")}) + _obj = cls.model_validate( + { + "logs": ( + [DistributionLogsRecord.from_dict(_item) for _item in obj["logs"]] + if obj.get("logs") is not None + else None + ), + "nextPageIdentifier": obj.get("nextPageIdentifier"), + } + ) return _obj diff --git a/services/cdn/src/stackit/cdn/models/status_error.py b/services/cdn/src/stackit/cdn/models/status_error.py index 12f37a1c..3153490f 100644 --- a/services/cdn/src/stackit/cdn/models/status_error.py +++ b/services/cdn/src/stackit/cdn/models/status_error.py @@ -41,9 +41,11 @@ class StatusError(BaseModel): @field_validator("key") def key_validate_enum(cls, value): """Validates the enum""" - if value not in set(["UNKNOWN", "CUSTOM_DOMAIN_CNAME_MISSING", "CUSTOM_DOMAIN_ALREADY_IN_USE"]): + if value not in set( + ["UNKNOWN", "CUSTOM_DOMAIN_CNAME_MISSING", "CUSTOM_DOMAIN_ALREADY_IN_USE", "PUBLIC_BETA_QUOTA_REACHED"] + ): raise ValueError( - "must be one of enum values ('UNKNOWN', 'CUSTOM_DOMAIN_CNAME_MISSING', 'CUSTOM_DOMAIN_ALREADY_IN_USE')" + "must be one of enum values ('UNKNOWN', 'CUSTOM_DOMAIN_CNAME_MISSING', 'CUSTOM_DOMAIN_ALREADY_IN_USE', 'PUBLIC_BETA_QUOTA_REACHED')" ) return value