|
12 | 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
| 15 | +from typing import Literal |
15 | 16 |
|
16 | 17 | from libcloud.storage.drivers.s3 import ( |
17 | 18 | S3_CDN_URL_EXPIRY_HOURS, |
@@ -83,7 +84,31 @@ def __init__( |
83 | 84 | def list_regions(self): |
84 | 85 | return REGION_TO_HOST_MAP.keys() |
85 | 86 |
|
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 | + """ |
87 | 112 | # In order to download (private) objects we need to be able to generate a valid CDN URL, |
88 | 113 | # hence shamefully just use the working code from the S3StorageDriver. |
89 | 114 | return S3StorageDriver.get_object_cdn_url( |
|
0 commit comments