Skip to content

Commit 1171660

Browse files
better docs
1 parent 72262a8 commit 1171660

4 files changed

Lines changed: 61 additions & 2 deletions

File tree

libcloud/storage/drivers/azure_blobs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,10 @@ def get_object_cdn_url(
620620
Defaults to 24 hours.
621621
:type ex_expiry: ``float``
622622
623+
:param ex_method: The HTTP method for which the URL is valid.
624+
Defaults to "GET".
625+
:type ex_method: ``str``
626+
623627
:return: A SAS URL for the object.
624628
:rtype: ``str``
625629
"""

libcloud/storage/drivers/ovh.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
from typing import Literal
1516

1617
from libcloud.storage.drivers.s3 import (
1718
S3_CDN_URL_EXPIRY_HOURS,
@@ -83,7 +84,31 @@ def __init__(
8384
def list_regions(self):
8485
return REGION_TO_HOST_MAP.keys()
8586

86-
def get_object_cdn_url(self, obj, ex_expiry=S3_CDN_URL_EXPIRY_HOURS, ex_method: str = "GET"):
87+
def get_object_cdn_url(
88+
self,
89+
obj,
90+
ex_expiry=S3_CDN_URL_EXPIRY_HOURS,
91+
ex_method: Literal["GET", "PUT", "DELETE"] = "GET",
92+
):
93+
"""
94+
Return a "presigned URL" for read-only access to object
95+
96+
:param obj: Object instance.
97+
:type obj: :class:`Object`
98+
99+
:param ex_expiry: The number of hours after which the URL expires.
100+
Defaults to 24 hours or the value of the environment
101+
variable "LIBCLOUD_S3_STORAGE_CDN_URL_EXPIRY_HOURS",
102+
if set.
103+
:type ex_expiry: ``float``
104+
105+
:param ex_method: The HTTP method for which the URL is valid.
106+
Defaults to "GET".
107+
:type ex_method: ``str``
108+
109+
:return: Presigned URL for the object.
110+
:rtype: ``str``
111+
"""
87112
# In order to download (private) objects we need to be able to generate a valid CDN URL,
88113
# hence shamefully just use the working code from the S3StorageDriver.
89114
return S3StorageDriver.get_object_cdn_url(

libcloud/storage/drivers/s3.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,10 @@ def get_object_cdn_url(
12951295
if set.
12961296
:type ex_expiry: ``float``
12971297
1298+
:param ex_method: The HTTP method for which the URL is valid.
1299+
Defaults to "GET".
1300+
:type ex_method: ``str``
1301+
12981302
:return: Presigned URL for the object.
12991303
:rtype: ``str``
13001304
"""

libcloud/storage/drivers/scaleway.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
from typing import Literal
17+
1618
from libcloud.storage.drivers.s3 import (
1719
S3_CDN_URL_EXPIRY_HOURS,
1820
S3StorageDriver,
@@ -85,7 +87,31 @@ def __init__(
8587
def list_regions(self):
8688
return REGION_TO_HOST_MAP.keys()
8789

88-
def get_object_cdn_url(self, obj, ex_expiry=S3_CDN_URL_EXPIRY_HOURS, ex_method: str = "GET"):
90+
def get_object_cdn_url(
91+
self,
92+
obj,
93+
ex_expiry=S3_CDN_URL_EXPIRY_HOURS,
94+
ex_method: Literal["GET", "PUT", "DELETE"] = "GET",
95+
):
96+
"""
97+
Return a "presigned URL" for read-only access to object
98+
99+
:param obj: Object instance.
100+
:type obj: :class:`Object`
101+
102+
:param ex_expiry: The number of hours after which the URL expires.
103+
Defaults to 24 hours or the value of the environment
104+
variable "LIBCLOUD_S3_STORAGE_CDN_URL_EXPIRY_HOURS",
105+
if set.
106+
:type ex_expiry: ``float``
107+
108+
:param ex_method: The HTTP method for which the URL is valid.
109+
Defaults to "GET".
110+
:type ex_method: ``str``
111+
112+
:return: Presigned URL for the object.
113+
:rtype: ``str``
114+
"""
89115
# In order to download (private) objects we need to be able to generate a valid CDN URL,
90116
# hence shamefully just use the working code from the S3StorageDriver.
91117
return S3StorageDriver.get_object_cdn_url(

0 commit comments

Comments
 (0)