@@ -534,17 +534,43 @@ Serialize and write data to `io::AzObject`. See serialize(conainer, blobname, d
534534Serialization. serialize (o:: AzObject , data) = serialize (o. container, o. name, data)
535535
536536"""
537- touch(container, "blobname" )
537+ touch(c, b )
538538
539- Create a zero-byte object with name `blobname` in `container::AzContainer`.
539+ Update the metadata of a blob `b::AbstractString` in container `c::AzContainer`, changing
540+ the datset's 'LAST MODIFIED' date. If the blob does not exist, then a zero-byte blob is
541+ created.
540542
541543# Example
542544```
543545container = AzContainer("mycontainer";storageaccount="mystorageaccount")
544546touch(container, "foo")
545547```
546548"""
547- Base. touch (c:: AzContainer , o:: AbstractString ) = write (c, o, " \0 " )
549+ function Base. touch (c:: AzContainer , o:: AbstractString )
550+ if ! isfile (c, o)
551+ write (c, o, " \0 " )
552+ else
553+ @retry c. nretry HTTP. request (
554+ " PUT" ,
555+ " https://$(c. storageaccount) .blob.core.windows.net/$(c. containername) /$(addprefix (c,o)) ?comp=metadata" ,
556+ [
557+ " Authorization" => " Bearer $(token (c. session)) " ,
558+ " x-ms-version" => API_VERSION,
559+ " x-ms-meta-touched" => string (Dates. now (UTC))
560+ ];
561+ retry = false ,
562+ verbose = c. verbose,
563+ connect_timeout = c. connect_timeout,
564+ readtimeout = c. read_timeout)
565+ end
566+ end
567+
568+ """
569+ touch(o)
570+
571+ Update the metadata of a blob `o::AzObject`, changing the dataset's 'LAST MODIFIED' date.
572+ """
573+ Base. touch (o:: AzObject ) = touch (o. container, o. name)
548574
549575"""
550576 touch(io::AzObject)
@@ -1416,6 +1442,96 @@ Note that the information stored is global, and not specfic to any one given IO
14161442"""
14171443getperf_counters () = @ccall libAzStorage. getperf_counters ():: PerfCounters
14181444
1419- export AzContainer, containers, readdlm, status, writedlm
1445+ """
1446+ tier!(c, b[; tier="Hot"])
1447+
1448+ Change the storage tier of a blob where `b::AbstractString` is the blob within a
1449+ container `c::AzContainer`, and `tier` is the target access tier which can be one
1450+ of `"Hot"`, `"Cool"`, `"Cold"` and `"Archive"`.
1451+
1452+ Notes:
1453+
1454+ * `tier!` throws an HTTP exception as appropriate. For example an HTTP exception
1455+ with a 409 error code is thrown when a blob has a pending tier change operation.
1456+ """
1457+ function tier! (c:: AzContainer , o:: AbstractString ; tier= " Hot" )
1458+ tier ∈ (" Hot" , " Cool" , " Cold" , " Archive" ) || error (" 'tier' must be one of 'Hot','Cool','Cold','Archive'" )
1459+
1460+ @retry c. nretry HTTP. request (
1461+ " PUT" ,
1462+ " https://$(c. storageaccount) .blob.core.windows.net/$(c. containername) /$(addprefix (c,o)) ?comp=tier" ,
1463+ [
1464+ " Authorization" => " Bearer $(token (c. session)) " ,
1465+ " x-ms-access-tier" => tier,
1466+ " x-ms-version" => API_VERSION
1467+ ];
1468+ retry = false ,
1469+ verbose = c. verbose,
1470+ connect_timeout = c. connect_timeout,
1471+ readtimeout = c. read_timeout)
1472+
1473+ # if we don't touch the blob, then existing lifecycle rules in the container might immediately change its tier back to what it was
1474+ touch (c, o)
1475+
1476+ nothing
1477+ end
1478+
1479+ """
1480+ tier!(o[; tier="Hot"])
1481+
1482+ Change the storage tier for a blob `o::AzObject`, and `tier` is the target
1483+ access tier which can be one of `"Hot"`, `"Cool"` and `"Archive"`.
1484+
1485+ Notes:
1486+
1487+ * `tier!` throws an HTTP exception as appropriate. For example an HTTP exception
1488+ with a 409 error code is thrown when a blob has a pending tier change operation.
1489+ """
1490+ tier! (o:: AzObject ; tier= " Hot" ) = tier! (o. container, o. name; tier)
1491+
1492+ """
1493+ tier!(c[; tier="Hot", ntasks=100])
1494+
1495+ Change the storage tier for all blobs within a container `c::AzContainer`. The
1496+ request for each blob in the container will be done asynchronously in batches
1497+ with `ntasks` tasks within each batch.
1498+
1499+ Notes:
1500+
1501+ * `tier!` throws an HTTP exception as appropriate. For example an HTTP exception
1502+ with a 409 error code is thrown when a blob has a pending tier change operation.
1503+ """
1504+ tier! (c:: AzContainer ; tier= " Hot" , ntasks= 100 ) = asyncmap (b-> tier! (c, b; tier), readdir (c); ntasks)
1505+
1506+ """
1507+ tier(c, o)
1508+
1509+ Returns the access tier for a blob `o::AbstractArray` in container `c::AzContainer`.
1510+ """
1511+ function tier (c:: AzContainer , o:: AbstractString )
1512+ r = HTTP. request (
1513+ " HEAD" ,
1514+ " https://$(c. storageaccount) .blob.core.windows.net/$(c. containername) /$(addprefix (c,o)) " ,
1515+ [
1516+ " Authorization" => " Bearer $(token (c. session)) " ,
1517+ " x-ms-access-tier" => tier,
1518+ " x-ms-version" => API_VERSION
1519+ ];
1520+ retry = false ,
1521+ verbose = c. verbose,
1522+ connect_timeout = c. connect_timeout,
1523+ readtimeout = c. read_timeout)
1524+
1525+ HTTP. header (r. headers, " x-ms-access-tier" )
1526+ end
1527+
1528+ """
1529+ tier(o)
1530+
1531+ Returns the access tier for a blob `o::AzObject`.
1532+ """
1533+ tier (o:: AzObject ) = tier (o. container, o. name)
1534+
1535+ export AzContainer, containers, readdlm, status, tier, tier!, writedlm
14201536
14211537end
0 commit comments