Skip to content

Commit

Permalink
Merge branch 'dev' into proj/multicluster-obj
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai authored Jun 18, 2024
2 parents aa7dbcb + 78574da commit 8d47be4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 5 additions & 3 deletions linode_api4/objects/object_storage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Optional
from urllib import parse

from deprecated import deprecated
Expand All @@ -10,10 +11,11 @@
Property,
Region,
)
from linode_api4.objects.serializable import StrEnum
from linode_api4.util import drop_null_keys


class ObjectStorageACL:
class ObjectStorageACL(StrEnum):
PRIVATE = "private"
PUBLIC_READ = "public-read"
AUTHENTICATED_READ = "authenticated-read"
Expand Down Expand Up @@ -69,7 +71,7 @@ def make_instance(cls, id, client, parent_id=None, json=None):

def access_modify(
self,
acl: ObjectStorageACL = None,
acl: Optional[ObjectStorageACL] = None,
cors_enabled=None,
):
"""
Expand Down Expand Up @@ -111,7 +113,7 @@ def access_modify(

def access_update(
self,
acl: ObjectStorageACL = None,
acl: Optional[ObjectStorageACL] = None,
cors_enabled=None,
):
"""
Expand Down
20 changes: 20 additions & 0 deletions linode_api4/objects/serializable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import inspect
from dataclasses import dataclass
from enum import Enum
from types import SimpleNamespace
from typing import (
Any,
Expand Down Expand Up @@ -223,3 +224,22 @@ def __delitem__(self, key):

def __len__(self):
return len(vars(self))


class StrEnum(str, Enum):
"""
Used for enums that are of type string, which is necessary
for implicit JSON serialization.
NOTE: Replace this with StrEnum once Python 3.10 has been EOL'd.
See: https://docs.python.org/3/library/enum.html#enum.StrEnum
"""

def __new__(cls, *values):
value = str(*values)
member = str.__new__(cls, value)
member._value_ = value
return member

def __str__(self):
return self._value_

0 comments on commit 8d47be4

Please sign in to comment.