Skip to content

Commit

Permalink
Return date in RFC-3339 fromat on upload credentials endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dblenkus committed Jul 25, 2024
1 parent f86e90c commit add12fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions resolwe/storage/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Storage Utils."""


def iso8601_to_rfc3339(iso_string):
"""Convert ISO8601 to RFC3339 format."""
if "+" in iso_string or "-" in iso_string:
offset_sign = "+" if "+" in iso_string else "-"
date_time, offset = iso_string.split(offset_sign)
offset = offset[:2] + ":" + offset[2:]
return date_time + offset_sign + offset

return iso_string
3 changes: 2 additions & 1 deletion resolwe/storage/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from resolwe.storage.connectors import connectors
from resolwe.storage.connectors.baseconnector import BaseStorageConnector
from resolwe.storage.models import FileStorage, ReferencedPath
from resolwe.storage.utils import iso8601_to_rfc3339
from resolwe.test.utils import ignore_in_tests

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -79,7 +80,7 @@ def get(self, request, *args, **kwargs):
"AccessKeyId": credentials["AccessKeyId"],
"SecretAccessKey": credentials["SecretAccessKey"],
"Token": credentials["SessionToken"],
"Expiration": credentials["Expiration"],
"Expiration": iso8601_to_rfc3339(credentials["Expiration"]),
}
return Response(self.serializer_class(response).data)

Expand Down

0 comments on commit add12fd

Please sign in to comment.