hetznercloud / hcloud-python

A Python library for the Hetzner Cloud API
MIT License
276 stars 42 forks source link

Failed to update the labels for BoundImage #340

Closed agusmakmun closed 9 months ago

agusmakmun commented 9 months ago
        snapshot: BoundImage = tools.get_snapshot(...)
        # set the snapshot as expired
        expiration_date: timezone.datetime.date = timezone.now() - timezone.timedelta(
            days=2
        )
>       snapshot.update(labels={"expiration_date": expiration_date.isoformat()})

practical_devsecops_cloud_labs/tests/webssh/test_task.py:832:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/site-packages/hcloud/images/client.py:90: in update
    return self._client.update(self, description, type, labels)
/usr/local/lib/python3.8/site-packages/hcloud/images/client.py:357: in update
    response = self._client.request(
/usr/local/lib/python3.8/site-packages/hcloud/_client.py:228: in request
    self._raise_exception_from_content(content)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <hcloud._client.Client object at 0x7f5c4f5f8340>, content = {'error': {'code': 'invalid_input', 'details': {'fields': [{'messages': ['invalid label value'], 'name': 'labels'}]}, 'message': "invalid input in field 'labels'"}}
agusmakmun commented 9 months ago

Oh my bad, it should be like this (using date instead of datetime):

expiration_date: timezone.datetime.date = (timezone.now() - timezone.timedelta(
    days=2
)).date()