Skip to content

Commit

Permalink
Merge pull request #271 from uploadcare/feature/261-deprecate_group_s…
Browse files Browse the repository at this point in the history
…tore

Add deprecation warnings for GroupsAPI.storage and FileGroup.datetime_stored, fixes #261
  • Loading branch information
evgkirov authored Dec 1, 2023
2 parents f491abb + 14e13fd commit 9128375
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.2.3](https://github.com/uploadcare/pyuploadcare/compare/v4.2.2...v4.2.3) - unreleased

### Deprecated

- For `FileGroup`:
- Added a deprecation warning when accessing `datetime_stored` property, as it has been deprecated in the REST API. This field does not exist in REST API v0.7.x.

- For `GroupsAPI`:
- Added a deprecation warning when calling `store` method, as it has been deprecated in the REST API. This API endpoint does not exist in REST API v0.7.x.

## [4.2.2](https://github.com/uploadcare/pyuploadcare/compare/v4.2.1...v4.2.2) - 2023-11-20

### Added
Expand Down
6 changes: 6 additions & 0 deletions pyuploadcare/api/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hashlib
import hmac
import logging
import warnings
from json import JSONDecodeError
from time import time
from typing import Any, Dict, Iterable, List, Optional, Type, Union, cast
Expand Down Expand Up @@ -122,6 +123,11 @@ class GroupsAPI(API, ListCountMixin, RetrieveMixin, DeleteMixin):
}

def store(self, file_uuid: Union[UUID, str]) -> Dict[str, Any]:
warnings.warn(
"/groups/:uuid/storage/ endpoint has been removed from REST API v0.7"
"https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Changelog",
DeprecationWarning,
)
url = self._build_url(file_uuid, suffix="storage")
return self._client.put(url).json()

Expand Down
5 changes: 5 additions & 0 deletions pyuploadcare/resources/file_group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import warnings
from datetime import datetime
from typing import TYPE_CHECKING, Any, Dict, Iterable, Iterator, Optional

Expand Down Expand Up @@ -152,6 +153,10 @@ def update_info(self):
@property
def datetime_stored(self):
"""Returns file group's store aware *datetime* in UTC format."""
warnings.warn(
"datetime_stored has been removed from REST API v0.7",
DeprecationWarning,
)
datetime_ = self.info.get("datetime_stored")
if isinstance(datetime_, str):
return dateutil.parser.parse(datetime_)
Expand Down

0 comments on commit 9128375

Please sign in to comment.