From 0bd3bf4d982af045501b8f04dc0536a7d8ee7929 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Fri, 21 Aug 2020 12:06:15 -0700 Subject: [PATCH 1/2] Added code to monitor last access time --- .../AzureBlobStorageBuilder.java | 2 +- .../models/BlobDownloadHeaders.java | 38 +++++ .../models/BlobGetPropertiesHeaders.java | 38 +++++ .../models/BlobItemPropertiesInternal.java | 33 ++++ .../blob/implementation/util/ModelHelper.java | 31 ++++ .../blob/models/BlobDownloadHeaders.java | 26 +++ .../blob/models/BlobItemProperties.java | 26 +++ .../storage/blob/models/BlobProperties.java | 152 ++++++++++-------- .../blob/specialized/BlobAsyncClientBase.java | 41 ++--- .../blob/specialized/BlobInputStream.java | 20 ++- .../com/azure/storage/blob/BlobAPITest.groovy | 2 + .../storage/blob/ContainerAPITest.groovy | 10 ++ .../BlobAPITestdownloadallnull.json | 121 +++++++------- .../BlobAPITestgetpropertiesdefault.json | 119 +++++++------- ...estlistblobsflatoptionslastaccesstime.json | 112 +++++++++++++ .../azure-storage-blob/swagger/README.md | 2 +- 16 files changed, 557 insertions(+), 216 deletions(-) create mode 100644 sdk/storage/azure-storage-blob/src/test/resources/session-records/ContainerAPITestlistblobsflatoptionslastaccesstime.json diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageBuilder.java index 9e9f770b0c014..47ebee34248c9 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageBuilder.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageBuilder.java @@ -97,7 +97,7 @@ public AzureBlobStorageImpl build() { if (this.version != null) { client.setVersion(this.version); } else { - client.setVersion("2019-12-12"); + client.setVersion("2020-02-10"); } if (this.pathRenameMode != null) { client.setPathRenameMode(this.pathRenameMode); diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobDownloadHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobDownloadHeaders.java index 21367e69021fe..f85365cb09767 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobDownloadHeaders.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobDownloadHeaders.java @@ -311,6 +311,13 @@ public final class BlobDownloadHeaders { @JsonProperty(value = "x-ms-blob-sealed") private Boolean isSealed; + /* + * UTC date/time value generated by the service that indicates the time at + * which the blob was last read or written to + */ + @JsonProperty(value = "x-ms-last-access-time") + private DateTimeRfc1123 lastAccessed; + /* * If the request is to read a specified range and the * x-ms-range-get-content-crc64 is set to true, then the request returns a @@ -1249,6 +1256,37 @@ public BlobDownloadHeaders setIsSealed(Boolean isSealed) { return this; } + /** + * Get the lastAccessed property: UTC date/time value generated by the + * service that indicates the time at which the blob was last read or + * written to. + * + * @return the lastAccessed value. + */ + public OffsetDateTime getLastAccessed() { + if (this.lastAccessed == null) { + return null; + } + return this.lastAccessed.getDateTime(); + } + + /** + * Set the lastAccessed property: UTC date/time value generated by the + * service that indicates the time at which the blob was last read or + * written to. + * + * @param lastAccessed the lastAccessed value to set. + * @return the BlobDownloadHeaders object itself. + */ + public BlobDownloadHeaders setLastAccessed(OffsetDateTime lastAccessed) { + if (lastAccessed == null) { + this.lastAccessed = null; + } else { + this.lastAccessed = new DateTimeRfc1123(lastAccessed); + } + return this; + } + /** * Get the contentCrc64 property: If the request is to read a specified * range and the x-ms-range-get-content-crc64 is set to true, then the diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobGetPropertiesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobGetPropertiesHeaders.java index 8c6d9bd1aedfd..5b6431c8d0bfd 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobGetPropertiesHeaders.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobGetPropertiesHeaders.java @@ -368,6 +368,13 @@ public final class BlobGetPropertiesHeaders { @JsonProperty(value = "x-ms-rehydrate-priority") private String rehydratePriority; + /* + * UTC date/time value generated by the service that indicates the time at + * which the blob was last read or written to + */ + @JsonProperty(value = "x-ms-last-access-time") + private DateTimeRfc1123 lastAccessed; + /* * The errorCode property. */ @@ -1509,6 +1516,37 @@ public BlobGetPropertiesHeaders setRehydratePriority(String rehydratePriority) { return this; } + /** + * Get the lastAccessed property: UTC date/time value generated by the + * service that indicates the time at which the blob was last read or + * written to. + * + * @return the lastAccessed value. + */ + public OffsetDateTime getLastAccessed() { + if (this.lastAccessed == null) { + return null; + } + return this.lastAccessed.getDateTime(); + } + + /** + * Set the lastAccessed property: UTC date/time value generated by the + * service that indicates the time at which the blob was last read or + * written to. + * + * @param lastAccessed the lastAccessed value to set. + * @return the BlobGetPropertiesHeaders object itself. + */ + public BlobGetPropertiesHeaders setLastAccessed(OffsetDateTime lastAccessed) { + if (lastAccessed == null) { + this.lastAccessed = null; + } else { + this.lastAccessed = new DateTimeRfc1123(lastAccessed); + } + return this; + } + /** * Get the errorCode property: The errorCode property. * diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java index c27cb28ac40fb..2197b34252a9b 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java @@ -244,6 +244,12 @@ public final class BlobItemPropertiesInternal { @JsonProperty(value = "RehydratePriority") private RehydratePriority rehydratePriority; + /* + * The lastAccessedOn property. + */ + @JsonProperty(value = "LastAccessTime") + private DateTimeRfc1123 lastAccessedOn; + /** * Get the creationTime property: The creationTime property. * @@ -1034,4 +1040,31 @@ public BlobItemPropertiesInternal setRehydratePriority(RehydratePriority rehydra this.rehydratePriority = rehydratePriority; return this; } + + /** + * Get the lastAccessedOn property: The lastAccessedOn property. + * + * @return the lastAccessedOn value. + */ + public OffsetDateTime getLastAccessedOn() { + if (this.lastAccessedOn == null) { + return null; + } + return this.lastAccessedOn.getDateTime(); + } + + /** + * Set the lastAccessedOn property: The lastAccessedOn property. + * + * @param lastAccessedOn the lastAccessedOn value to set. + * @return the BlobItemPropertiesInternal object itself. + */ + public BlobItemPropertiesInternal setLastAccessedOn(OffsetDateTime lastAccessedOn) { + if (lastAccessedOn == null) { + this.lastAccessedOn = null; + } else { + this.lastAccessedOn = new DateTimeRfc1123(lastAccessedOn); + } + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java index a8c9d8ee3d33b..49f72dc08270f 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java @@ -178,6 +178,7 @@ public static com.azure.storage.blob.models.BlobDownloadHeaders populateBlobDown } headers.setObjectReplicationSourcePolicies(objectReplicationSourcePolicies); headers.setSealed(internalHeaders.isSealed()); + headers.setLastAccessedTime(internalHeaders.getLastAccessed()); return headers; } @@ -256,6 +257,7 @@ public static BlobItemProperties populateBlobItemProperties(BlobItemPropertiesIn blobItemProperties.setTagCount(blobItemPropertiesInternal.getTagCount()); blobItemProperties.setRehydratePriority(blobItemPropertiesInternal.getRehydratePriority()); blobItemProperties.setSealed(blobItemPropertiesInternal.isSealed()); + blobItemProperties.setLastAccessedTime(blobItemPropertiesInternal.getLastAccessedOn()); return blobItemProperties; } @@ -346,4 +348,33 @@ public static PageBlobCopyIncrementalRequestConditions populateBlobDestinationRe .setIfUnmodifiedSince(requestConditions.getIfUnmodifiedSince()) .setTagsConditions(null); } + + public static String getObjectReplicationDestinationPolicyId(Map objectReplicationStatus) { + objectReplicationStatus = objectReplicationStatus == null ? new HashMap<>() : objectReplicationStatus; + return objectReplicationStatus.getOrDefault("policy-id", null); + } + + public static List getObjectReplicationSourcePolicies( + Map objectReplicationStatus) { + Map> internalSourcePolicies = new HashMap<>(); + objectReplicationStatus = objectReplicationStatus == null ? new HashMap<>() : objectReplicationStatus; + if (getObjectReplicationDestinationPolicyId(objectReplicationStatus) == null) { + for (Map.Entry entry : objectReplicationStatus.entrySet()) { + String[] split = entry.getKey().split("_"); + String policyId = split[0]; + String ruleId = split[1]; + ObjectReplicationRule rule = new ObjectReplicationRule(ruleId, + ObjectReplicationStatus.fromString(entry.getValue())); + if (!internalSourcePolicies.containsKey(policyId)) { + internalSourcePolicies.put(policyId, new ArrayList<>()); + } + internalSourcePolicies.get(policyId).add(rule); + } + } + List objectReplicationSourcePolicies = new ArrayList<>(); + for (Map.Entry> entry : internalSourcePolicies.entrySet()) { + objectReplicationSourcePolicies.add(new ObjectReplicationPolicy(entry.getKey(), entry.getValue())); + } + return objectReplicationSourcePolicies; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java index 4ea5620959112..6769e95577a44 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java @@ -325,6 +325,12 @@ public final class BlobDownloadHeaders { @JsonProperty(value = "IsSealed") private Boolean sealed; + /* + * The lastAccessedTime property. + */ + @JsonProperty(value = "LastAccessTime") + private OffsetDateTime lastAccessedTime; + /** * Get the lastModified property: Returns the date and time the container * was last modified. Any operation that modifies the blob, including an @@ -1277,4 +1283,24 @@ public BlobDownloadHeaders setSealed(Boolean sealed) { this.sealed = sealed; return this; } + + /** + * Get the lastAccessedTime property: The lastAccessedTime property. + * + * @return the lastAccessedTime value. + */ + public OffsetDateTime getLastAccessedTime() { + return this.lastAccessedTime; + } + + /** + * Set the lastAccessedTime property: The lastAccessedTime property. + * + * @param lastAccessedTime the lastAccessedTime value to set. + * @return the BlobDownloadHeaders object itself. + */ + public BlobDownloadHeaders setLastAccessedTime(OffsetDateTime lastAccessedTime) { + this.lastAccessedTime = lastAccessedTime; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java index 51c0f5b6145c6..df330ea329092 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java @@ -230,6 +230,12 @@ public final class BlobItemProperties { @JsonProperty(value = "Sealed") private Boolean sealed; + /* + * The lastAccessedTime property. + */ + @JsonProperty(value = "LastAccessTime") + private OffsetDateTime lastAccessedTime; + /** * Get the creationTime property: The creationTime property. * @@ -958,4 +964,24 @@ public BlobItemProperties setSealed(Boolean sealed) { this.sealed = sealed; return this; } + + /** + * Get the lastAccessedTime property: The lastAccessedTime property. + * + * @return the lastAccessedTime value. + */ + public OffsetDateTime getLastAccessedTime() { + return this.lastAccessedTime; + } + + /** + * Set the lastAccessedTime property: The lastAccessedTime property. + * + * @param lastAccessedTime the lastAccessedTime value to set. + * @return the BlobItemProperties object itself. + */ + public BlobItemProperties setLastAccessedTime(OffsetDateTime lastAccessedTime) { + this.lastAccessedTime = lastAccessedTime; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java index 96e449985e91f..1b8eecfebc035 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java @@ -5,11 +5,10 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.CoreUtils; +import com.azure.storage.blob.implementation.util.ModelHelper; import java.time.OffsetDateTime; -import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -57,6 +56,7 @@ public final class BlobProperties { private final String objectReplicationDestinationPolicyId; private final RehydratePriority rehydratePriority; private final Boolean isSealed; + private final OffsetDateTime lastAccessedTime; /** * Constructs a {@link BlobProperties}. @@ -173,67 +173,16 @@ public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime la final Integer committedBlockCount, final String versionId, final Boolean isCurrentVersion, final Long tagCount, Map objectReplicationStatus, final String rehydratePriority, final Boolean isSealed) { - this.creationTime = creationTime; - this.lastModified = lastModified; - this.eTag = eTag; - this.blobSize = blobSize; - this.contentType = contentType; - this.contentMd5 = CoreUtils.clone(contentMd5); - this.contentEncoding = contentEncoding; - this.contentDisposition = contentDisposition; - this.contentLanguage = contentLanguage; - this.cacheControl = cacheControl; - this.blobSequenceNumber = blobSequenceNumber; - this.blobType = blobType; - this.leaseStatus = leaseStatus; - this.leaseState = leaseState; - this.leaseDuration = leaseDuration; - this.copyId = copyId; - this.copyStatus = copyStatus; - this.copySource = copySource; - this.copyProgress = copyProgress; - this.copyCompletionTime = copyCompletionTime; - this.copyStatusDescription = copyStatusDescription; - this.isServerEncrypted = isServerEncrypted; - this.isIncrementalCopy = isIncrementalCopy; - this.copyDestinationSnapshot = copyDestinationSnapshot; - this.accessTier = accessTier; - this.isAccessTierInferred = isAccessTierInferred; - this.archiveStatus = archiveStatus; - this.encryptionKeySha256 = encryptionKeySha256; - this.encryptionScope = encryptionScope; - this.accessTierChangeTime = accessTierChangeTime; - this.metadata = metadata; - this.committedBlockCount = committedBlockCount; - this.tagCount = tagCount; - this.versionId = versionId; - this.isCurrentVersion = isCurrentVersion; - - Map> internalSourcePolicies = new HashMap<>(); - objectReplicationStatus = objectReplicationStatus == null ? new HashMap<>() : objectReplicationStatus; - this.objectReplicationDestinationPolicyId = objectReplicationStatus.getOrDefault("policy-id", null); - if (this.objectReplicationDestinationPolicyId == null) { - for (Map.Entry entry : objectReplicationStatus.entrySet()) { - String[] split = entry.getKey().split("_"); - String policyId = split[0]; - String ruleId = split[1]; - ObjectReplicationRule rule = new ObjectReplicationRule(ruleId, - ObjectReplicationStatus.fromString(entry.getValue())); - if (!internalSourcePolicies.containsKey(policyId)) { - internalSourcePolicies.put(policyId, new ArrayList<>()); - } - internalSourcePolicies.get(policyId).add(rule); - } - } - this.objectReplicationSourcePolicies = new ArrayList<>(); - for (Map.Entry> entry : internalSourcePolicies.entrySet()) { - this.objectReplicationSourcePolicies.add(new ObjectReplicationPolicy(entry.getKey(), entry.getValue())); - } - this.rehydratePriority = RehydratePriority.fromString(rehydratePriority); - this.isSealed = isSealed; + this(creationTime, lastModified, eTag, blobSize, contentType, contentMd5, contentEncoding, contentDisposition, + contentLanguage, cacheControl, blobSequenceNumber, blobType, leaseStatus, leaseState, leaseDuration, + copyId, copyStatus, copySource, copyProgress, copyCompletionTime, copyStatusDescription, isServerEncrypted, + isIncrementalCopy, copyDestinationSnapshot, accessTier, isAccessTierInferred, archiveStatus, + encryptionKeySha256, encryptionScope, accessTierChangeTime, metadata, committedBlockCount, tagCount, + versionId, isCurrentVersion, ModelHelper.getObjectReplicationSourcePolicies(objectReplicationStatus), + ModelHelper.getObjectReplicationDestinationPolicyId(objectReplicationStatus), + RehydratePriority.fromString(rehydratePriority), isSealed, null); } - /** * Constructs a {@link BlobProperties}. * @@ -291,7 +240,76 @@ public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime la final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, List objectReplicationSourcePolicies, String objectReplicationDestinationPolicyId) { + this(creationTime, lastModified, eTag, blobSize, contentType, contentMd5, contentEncoding, contentDisposition, + contentLanguage, cacheControl, blobSequenceNumber, blobType, leaseStatus, leaseState, leaseDuration, + copyId, copyStatus, copySource, copyProgress, copyCompletionTime, copyStatusDescription, isServerEncrypted, + isIncrementalCopy, copyDestinationSnapshot, accessTier, isAccessTierInferred, archiveStatus, + encryptionKeySha256, encryptionScope, accessTierChangeTime, metadata, committedBlockCount, tagCount, + versionId, isCurrentVersion, objectReplicationSourcePolicies, objectReplicationDestinationPolicyId, + null, null, null); + } + /** + * Constructs a {@link BlobProperties}. + * + * @param creationTime Creation time of the blob. + * @param lastModified Datetime when the blob was last modified. + * @param eTag ETag of the blob. + * @param blobSize Size of the blob. + * @param contentType Content type specified for the blob. + * @param contentMd5 Content MD5 specified for the blob. + * @param contentEncoding Content encoding specified for the blob. + * @param contentDisposition Content disposition specified for the blob. + * @param contentLanguage Content language specified for the blob. + * @param cacheControl Cache control specified for the blob. + * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob + * pass {@code null}. + * @param blobType Type of the blob. + * @param leaseStatus Status of the lease on the blob. + * @param leaseState State of the lease on the blob. + * @param leaseDuration Type of lease on the blob. + * @param copyId Identifier of the last copy operation performed on the blob. + * @param copyStatus Status of the last copy operation performed on the blob. + * @param copySource Source of the last copy operation performed on the blob. + * @param copyProgress Progress of the last copy operation performed on the blob. + * @param copyCompletionTime Datetime when the last copy operation on the blob completed. + * @param copyStatusDescription Description of the last copy operation on the blob. + * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. + * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. + * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. + * @param accessTier Access tier of the blob. + * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the + * blob. + * @param archiveStatus Archive status of the blob. + * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the server. + * @param encryptionScope The name of the encryption scope under which the blob is encrypted. + * @param accessTierChangeTime Datetime when the access tier of the blob last changed. + * @param metadata Metadata associated with the blob. + * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob + * pass {@code null}. + * @param versionId The version identifier of the blob. + * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. + * @param tagCount Number of tags associated with the blob. + * @param objectReplicationSourcePolicies The already parsed object replication policies. + * @param objectReplicationDestinationPolicyId The policy id on the destination blob. + * @param rehydratePriority The rehydrate priority + * @param isSealed Whether or not the blob is sealed. + * @param lastAccessedTime The date and time the blob was read or written to. + */ + public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime lastModified, final String eTag, + final long blobSize, final String contentType, final byte[] contentMd5, final String contentEncoding, + final String contentDisposition, final String contentLanguage, final String cacheControl, + final Long blobSequenceNumber, final BlobType blobType, final LeaseStatusType leaseStatus, + final LeaseStateType leaseState, final LeaseDurationType leaseDuration, final String copyId, + final CopyStatusType copyStatus, final String copySource, final String copyProgress, + final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, + final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, + final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, + final String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, + final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, + final List objectReplicationSourcePolicies, + final String objectReplicationDestinationPolicyId, final RehydratePriority rehydratePriority, + final Boolean isSealed, final OffsetDateTime lastAccessedTime) { this.creationTime = creationTime; this.lastModified = lastModified; this.eTag = eTag; @@ -329,8 +347,9 @@ public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime la this.isCurrentVersion = isCurrentVersion; this.objectReplicationSourcePolicies = objectReplicationSourcePolicies; this.objectReplicationDestinationPolicyId = objectReplicationDestinationPolicyId; - this.rehydratePriority = null; - this.isSealed = null; + this.rehydratePriority = rehydratePriority; + this.isSealed = isSealed; + this.lastAccessedTime = lastAccessedTime; } /** @@ -619,4 +638,11 @@ public RehydratePriority getRehydratePriority() { public Boolean isSealed() { return isSealed; } + + /** + * @return The date and time the blob was read or written to. + */ + public OffsetDateTime getLastAccessedTime() { + return lastAccessedTime; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java index c737a49265e23..40eaf63e91aef 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java @@ -1049,28 +1049,18 @@ private static Mono writeBodyToFile(BlobDownloadAsyncResponse response, As private static Response buildBlobPropertiesResponse(BlobDownloadAsyncResponse response) { // blobSize determination - contentLength only returns blobSize if the download is not chunked. - long blobSize = getBlobLength(response.getDeserializedHeaders()); - BlobProperties properties = new BlobProperties(null, response.getDeserializedHeaders().getLastModified(), - response.getDeserializedHeaders().getETag(), blobSize, response.getDeserializedHeaders().getContentType(), - null, response.getDeserializedHeaders().getContentEncoding(), - response.getDeserializedHeaders().getContentDisposition(), - response.getDeserializedHeaders().getContentLanguage(), response.getDeserializedHeaders().getCacheControl(), - response.getDeserializedHeaders().getBlobSequenceNumber(), response.getDeserializedHeaders().getBlobType(), - response.getDeserializedHeaders().getLeaseStatus(), response.getDeserializedHeaders().getLeaseState(), - response.getDeserializedHeaders().getLeaseDuration(), response.getDeserializedHeaders().getCopyId(), - response.getDeserializedHeaders().getCopyStatus(), response.getDeserializedHeaders().getCopySource(), - response.getDeserializedHeaders().getCopyProgress(), - response.getDeserializedHeaders().getCopyCompletionTime(), - response.getDeserializedHeaders().getCopyStatusDescription(), - response.getDeserializedHeaders().isServerEncrypted(), null, null, null, null, null, - response.getDeserializedHeaders().getEncryptionKeySha256(), - response.getDeserializedHeaders().getEncryptionScope(), null, - response.getDeserializedHeaders().getMetadata(), - response.getDeserializedHeaders().getBlobCommittedBlockCount(), - response.getDeserializedHeaders().getTagCount(), - response.getDeserializedHeaders().getVersionId(), null, - response.getDeserializedHeaders().getObjectReplicationSourcePolicies(), - response.getDeserializedHeaders().getObjectReplicationDestinationPolicyId()); + BlobDownloadHeaders hd = response.getDeserializedHeaders(); + long blobSize = getBlobLength(hd); + BlobProperties properties = new BlobProperties(null, hd.getLastModified(), hd.getETag(), blobSize, + hd.getContentType(), hd.getContentMd5(), hd.getContentEncoding(), hd.getContentDisposition(), + hd.getContentLanguage(), hd.getCacheControl(), hd.getBlobSequenceNumber(), hd.getBlobType(), + hd.getLeaseStatus(), hd.getLeaseState(), hd.getLeaseDuration(), hd.getCopyId(), hd.getCopyStatus(), + hd.getCopySource(), hd.getCopyProgress(), hd.getCopyCompletionTime(), hd.getCopyStatusDescription(), + hd.isServerEncrypted(), null, null, null, null, null, + hd.getEncryptionKeySha256(), hd.getEncryptionScope(), null, hd.getMetadata(), + hd.getBlobCommittedBlockCount(), hd.getTagCount(), hd.getVersionId(), null, + hd.getObjectReplicationSourcePolicies(), hd.getObjectReplicationDestinationPolicyId(), null, + hd.isSealed(), null); return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), properties); } @@ -1210,8 +1200,11 @@ Mono> getPropertiesWithResponse(BlobRequestConditions r hd.isIncrementalCopy(), hd.getDestinationSnapshot(), AccessTier.fromString(hd.getAccessTier()), hd.isAccessTierInferred(), ArchiveStatus.fromString(hd.getArchiveStatus()), hd.getEncryptionKeySha256(), hd.getEncryptionScope(), hd.getAccessTierChangeTime(), - hd.getMetadata(), hd.getBlobCommittedBlockCount(), hd.getVersionId(), hd.isCurrentVersion(), - hd.getTagCount(), hd.getObjectReplicationRules(), hd.getRehydratePriority(), hd.isSealed()); + hd.getMetadata(), hd.getBlobCommittedBlockCount(), hd.getTagCount(), hd.getVersionId(), + hd.isCurrentVersion(), + ModelHelper.getObjectReplicationSourcePolicies(hd.getObjectReplicationRules()), + ModelHelper.getObjectReplicationDestinationPolicyId(hd.getObjectReplicationRules()), + RehydratePriority.fromString(hd.getRehydratePriority()), hd.isSealed(), hd.getLastAccessed()); return new SimpleResponse<>(rb, properties); }); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java index 8ec7602ca7223..ab18822f2a41a 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java @@ -4,6 +4,7 @@ import com.azure.core.util.FluxUtil; import com.azure.storage.blob.BlobAsyncClient; +import com.azure.storage.blob.implementation.util.ChunkedDownloadUtils; import com.azure.storage.blob.models.BlobDownloadHeaders; import com.azure.storage.blob.models.BlobProperties; import com.azure.storage.blob.models.BlobRange; @@ -106,15 +107,18 @@ private static BlobProperties buildBlobProperties(BlobDownloadHeaders hd) { if (hd == null) { return null; } - return new BlobProperties(null, hd.getLastModified(), hd.getETag(), - hd.getContentLength() == null ? 0 : hd.getContentLength(), hd.getContentType(), null, - hd.getContentEncoding(), hd.getContentDisposition(), hd.getContentLanguage(), hd.getCacheControl(), - hd.getBlobSequenceNumber(), hd.getBlobType(), hd.getLeaseStatus(), hd.getLeaseState(), - hd.getLeaseDuration(), hd.getCopyId(), hd.getCopyStatus(), hd.getCopySource(), hd.getCopyProgress(), - hd.getCopyCompletionTime(), hd.getCopyStatusDescription(), hd.isServerEncrypted(), - null, null, null, null, null, hd.getEncryptionKeySha256(), hd.getEncryptionScope(), null, hd.getMetadata(), + long blobSize = hd.getContentRange() == null ? hd.getContentLength() + : ChunkedDownloadUtils.extractTotalBlobLength(hd.getContentRange()); + return new BlobProperties(null, hd.getLastModified(), hd.getETag(), blobSize, + hd.getContentType(), hd.getContentMd5(), hd.getContentEncoding(), hd.getContentDisposition(), + hd.getContentLanguage(), hd.getCacheControl(), hd.getBlobSequenceNumber(), hd.getBlobType(), + hd.getLeaseStatus(), hd.getLeaseState(), hd.getLeaseDuration(), hd.getCopyId(), hd.getCopyStatus(), + hd.getCopySource(), hd.getCopyProgress(), hd.getCopyCompletionTime(), hd.getCopyStatusDescription(), + hd.isServerEncrypted(), null, null, null, null, null, + hd.getEncryptionKeySha256(), hd.getEncryptionScope(), null, hd.getMetadata(), hd.getBlobCommittedBlockCount(), hd.getTagCount(), hd.getVersionId(), null, - hd.getObjectReplicationSourcePolicies(), hd.getObjectReplicationDestinationPolicyId()); + hd.getObjectReplicationSourcePolicies(), hd.getObjectReplicationDestinationPolicyId(), null, + hd.isSealed(), null); } /** diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy index 321ca5d4a659f..a5ac54e08eed6 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy @@ -227,6 +227,7 @@ class BlobAPITest extends APISpec { headers.getBlobCommittedBlockCount() == null headers.isServerEncrypted() != null headers.getBlobContentMD5() == null + headers.getLastAccessedTime() } def "Download empty file"() { @@ -945,6 +946,7 @@ class BlobAPITest extends APISpec { properties.getTagCount() == 1 properties.getRehydratePriority() == null // tested in setTier rehydrate priority !properties.isSealed() // tested in AppendBlob. "seal blob" + properties.getLastAccessedTime() } def "Get properties min"() { diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy index 10482467520e5..267c3c730a21e 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy @@ -779,6 +779,16 @@ class ContainerAPITest extends APISpec { blobs.size() == 4 // Normal, copy, metadata, tags } + def "List blobs flat options last access time"() { + when: + def b = cc.getBlobClient(generateBlobName()).getBlockBlobClient() + b.upload(defaultInputStream.get(), defaultData.remaining()) + def blob = cc.listBlobs().iterator().next() + + then: + blob.getProperties().getLastAccessedTime() + } + def "List blobs flat options tags"() { setup: def options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveTags(true)) diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestdownloadallnull.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestdownloadallnull.json index 9c4ee68971906..7c47fd212e96d 100644 --- a/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestdownloadallnull.json +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestdownloadallnull.json @@ -1,143 +1,144 @@ { "networkCallRecords" : [ { "Method" : "PUT", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnull0349281241286?restype=container", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnullecb00523faa79?restype=container", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "f77bad21-456e-4515-ade3-03e8973cb134" + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "a39da11e-ee47-4b8c-b0cf-dbff50acf4ff" }, "Response" : { - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "ETag" : "0x8D7E5778598220A", - "Last-Modified" : "Mon, 20 Apr 2020 22:09:40 GMT", + "ETag" : "0x8D845F9C2502B02", + "Last-Modified" : "Fri, 21 Aug 2020 17:43:48 GMT", "retry-after" : "0", "Content-Length" : "0", "StatusCode" : "201", - "x-ms-request-id" : "584c52f5-201e-003e-3160-17dadf000000", - "Date" : "Mon, 20 Apr 2020 22:09:39 GMT", - "x-ms-client-request-id" : "f77bad21-456e-4515-ade3-03e8973cb134" + "x-ms-request-id" : "cbb2cf2b-401e-0089-75e2-779f7c000000", + "Date" : "Fri, 21 Aug 2020 17:43:47 GMT", + "x-ms-client-request-id" : "a39da11e-ee47-4b8c-b0cf-dbff50acf4ff" }, "Exception" : null }, { "Method" : "PUT", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnull0349281241286/javablobdownloadallnull1blobapitestdownloadallnull034529723e", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnullecb00523faa79/javablobdownloadallnull1blobapitestdownloadallnullecb835196f", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "a0ef7c13-b99a-425c-b42b-634aa334da5a", + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "f5037b00-9502-45a2-9489-1080a6a3b029", "Content-Type" : "application/octet-stream" }, "Response" : { - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "x-ms-content-crc64" : "6RYQPwaVsyQ=", - "x-ms-version-id" : "2020-04-20T22:09:40.6304733Z", - "Last-Modified" : "Mon, 20 Apr 2020 22:09:40 GMT", + "x-ms-version-id" : "2020-08-21T17:43:48.5873811Z", + "Last-Modified" : "Fri, 21 Aug 2020 17:43:48 GMT", "retry-after" : "0", "StatusCode" : "201", "x-ms-request-server-encrypted" : "true", - "Date" : "Mon, 20 Apr 2020 22:09:39 GMT", + "Date" : "Fri, 21 Aug 2020 17:43:47 GMT", "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", - "ETag" : "0x8D7E57785E276C6", + "ETag" : "0x8D845F9C2894293", "Content-Length" : "0", - "x-ms-request-id" : "7db5ba53-301e-000d-3460-178574000000", - "x-ms-client-request-id" : "a0ef7c13-b99a-425c-b42b-634aa334da5a" + "x-ms-request-id" : "cbb2cf57-401e-0089-1ce2-779f7c000000", + "x-ms-client-request-id" : "f5037b00-9502-45a2-9489-1080a6a3b029" }, "Exception" : null }, { "Method" : "PUT", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnull0349281241286/javablobdownloadallnull1blobapitestdownloadallnull034529723e?comp=tags", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnullecb00523faa79/javablobdownloadallnull1blobapitestdownloadallnullecb835196f?comp=tags", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "31586f78-7c70-4356-82d6-962d2cbf5528", + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "40a6905c-d270-446e-8eab-9097f57d5892", "Content-Type" : "application/xml; charset=utf-8" }, "Response" : { - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "retry-after" : "0", "StatusCode" : "204", - "x-ms-request-id" : "2ca9ee4f-f01e-0070-2160-17f457000000", - "Date" : "Mon, 20 Apr 2020 22:09:40 GMT", - "x-ms-client-request-id" : "31586f78-7c70-4356-82d6-962d2cbf5528" + "x-ms-request-id" : "cbb2cf6a-401e-0089-2ee2-779f7c000000", + "Date" : "Fri, 21 Aug 2020 17:43:48 GMT", + "x-ms-client-request-id" : "40a6905c-d270-446e-8eab-9097f57d5892" }, "Exception" : null }, { "Method" : "GET", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnull0349281241286/javablobdownloadallnull1blobapitestdownloadallnull034529723e", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnullecb00523faa79/javablobdownloadallnull1blobapitestdownloadallnullecb835196f", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "594d6474-4236-461d-8d43-689140e66da6" + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e52cbbc1-ec07-4eca-9595-f88eaf2b2f23" }, "Response" : { "x-ms-is-current-version" : "true", - "x-ms-version" : "2019-12-12", + "x-ms-last-access-time" : "Fri, 21 Aug 2020 17:43:48 GMT", + "x-ms-version" : "2020-02-10", "x-ms-lease-status" : "unlocked", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "x-ms-tag-count" : "1", "x-ms-lease-state" : "available", - "x-ms-version-id" : "2020-04-20T22:09:40.6304733Z", - "Last-Modified" : "Mon, 20 Apr 2020 22:09:40 GMT", + "x-ms-version-id" : "2020-08-21T17:43:48.5873811Z", + "Last-Modified" : "Fri, 21 Aug 2020 17:43:48 GMT", "retry-after" : "0", "StatusCode" : "200", - "Date" : "Mon, 20 Apr 2020 22:09:41 GMT", + "Date" : "Fri, 21 Aug 2020 17:43:48 GMT", "x-ms-blob-type" : "BlockBlob", "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", "Accept-Ranges" : "bytes", "x-ms-server-encrypted" : "true", - "ETag" : "0x8D7E57785E276C6", - "x-ms-creation-time" : "Mon, 20 Apr 2020 22:09:40 GMT", + "ETag" : "0x8D845F9C2894293", + "x-ms-creation-time" : "Fri, 21 Aug 2020 17:43:48 GMT", "Content-Length" : "7", - "x-ms-request-id" : "f3b38bf2-f01e-002d-1060-17fed3000000", - "Body" : "[100, 101, 102, 97, 117, 108, 116]", - "x-ms-client-request-id" : "594d6474-4236-461d-8d43-689140e66da6", + "x-ms-request-id" : "cbb2cf7a-401e-0089-3ce2-779f7c000000", + "Body" : "ZGVmYXVsdA==", + "x-ms-client-request-id" : "e52cbbc1-ec07-4eca-9595-f88eaf2b2f23", "Content-Type" : "application/octet-stream" }, "Exception" : null }, { "Method" : "GET", - "Uri" : "https://blobindex1.blob.core.windows.net?prefix=jtcdownloadallnull&comp=list", + "Uri" : "https://REDACTED.blob.core.windows.net?prefix=jtcdownloadallnull&comp=list", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "22e210a5-b273-4cd5-94a4-b006f047cee2" + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "18871417-a72c-4aa5-bfb4-310523c5fd11" }, "Response" : { "Transfer-Encoding" : "chunked", - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "retry-after" : "0", "StatusCode" : "200", - "x-ms-request-id" : "3270ecd9-c01e-008f-7360-17c4ca000000", - "Body" : "jtcdownloadallnulljtcdownloadallnull0blobapitestdownloadallnull0349281241286Mon, 20 Apr 2020 22:09:40 GMT\"0x8D7E5778598220A\"unlockedavailable$account-encryption-keyfalsefalsefalse", - "Date" : "Mon, 20 Apr 2020 22:09:41 GMT", - "x-ms-client-request-id" : "22e210a5-b273-4cd5-94a4-b006f047cee2", + "x-ms-request-id" : "cbb2cf8c-401e-0089-4ce2-779f7c000000", + "Body" : "jtcdownloadallnulljtcdownloadallnull0blobapitestdownloadallnullecb00523faa79Fri, 21 Aug 2020 17:43:48 GMT\"0x8D845F9C2502B02\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Fri, 21 Aug 2020 17:43:48 GMT", + "x-ms-client-request-id" : "18871417-a72c-4aa5-bfb4-310523c5fd11", "Content-Type" : "application/xml" }, "Exception" : null }, { "Method" : "DELETE", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnull0349281241286?restype=container", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcdownloadallnull0blobapitestdownloadallnullecb00523faa79?restype=container", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "d29db498-de79-4d1b-bb5d-8e73a0e1ee3a" + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "dab7b1e7-6af8-4c86-b96c-ed6bdb0fb2b0" }, "Response" : { - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "retry-after" : "0", "Content-Length" : "0", "StatusCode" : "202", - "x-ms-request-id" : "f1a70bcd-701e-009a-4160-17d379000000", - "Date" : "Mon, 20 Apr 2020 22:09:41 GMT", - "x-ms-client-request-id" : "d29db498-de79-4d1b-bb5d-8e73a0e1ee3a" + "x-ms-request-id" : "cbb2cf9c-401e-0089-5ae2-779f7c000000", + "Date" : "Fri, 21 Aug 2020 17:43:48 GMT", + "x-ms-client-request-id" : "dab7b1e7-6af8-4c86-b96c-ed6bdb0fb2b0" }, "Exception" : null } ], - "variables" : [ "jtcdownloadallnull0blobapitestdownloadallnull0349281241286", "javablobdownloadallnull1blobapitestdownloadallnull034529723e" ] + "variables" : [ "jtcdownloadallnull0blobapitestdownloadallnullecb00523faa79", "javablobdownloadallnull1blobapitestdownloadallnullecb835196f" ] } \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestgetpropertiesdefault.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestgetpropertiesdefault.json index c56c6569fee99..e81ed99ea9d56 100644 --- a/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestgetpropertiesdefault.json +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestgetpropertiesdefault.json @@ -1,144 +1,145 @@ { "networkCallRecords" : [ { "Method" : "PUT", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcgetpropertiesdefault030262521e16065bfa4f74b?restype=container", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcgetpropertiesdefault00216945021d79e5a04cc7a?restype=container", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "87b61fa0-3f41-4e01-baca-3f2471b57ab2" + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e2411a15-41d6-4939-864e-13eb93c2e9cc" }, "Response" : { - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "ETag" : "0x8D7E57792D86E2A", - "Last-Modified" : "Mon, 20 Apr 2020 22:10:02 GMT", + "ETag" : "0x8D845F781BC4409", + "Last-Modified" : "Fri, 21 Aug 2020 17:27:40 GMT", "retry-after" : "0", "Content-Length" : "0", "StatusCode" : "201", - "x-ms-request-id" : "cb10ace6-c01e-0044-3f60-17c79f000000", - "Date" : "Mon, 20 Apr 2020 22:10:02 GMT", - "x-ms-client-request-id" : "87b61fa0-3f41-4e01-baca-3f2471b57ab2" + "x-ms-request-id" : "8d8ee54a-101e-003d-43e0-7753b2000000", + "Date" : "Fri, 21 Aug 2020 17:27:39 GMT", + "x-ms-client-request-id" : "e2411a15-41d6-4939-864e-13eb93c2e9cc" }, "Exception" : null }, { "Method" : "PUT", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcgetpropertiesdefault030262521e16065bfa4f74b/javablobgetpropertiesdefault1226465f6b058a8a404f", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcgetpropertiesdefault00216945021d79e5a04cc7a/javablobgetpropertiesdefault130243c9ea2682cd5e46", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "e6156bcf-999f-4776-83b7-7460e125cd31", + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "f9c5a876-8940-46a1-8760-9ad227d60755", "Content-Type" : "application/octet-stream" }, "Response" : { - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "x-ms-content-crc64" : "6RYQPwaVsyQ=", - "x-ms-version-id" : "2020-04-20T22:10:02.8922468Z", - "Last-Modified" : "Mon, 20 Apr 2020 22:10:02 GMT", + "x-ms-version-id" : "2020-08-21T17:27:41.3636097Z", + "Last-Modified" : "Fri, 21 Aug 2020 17:27:41 GMT", "retry-after" : "0", "StatusCode" : "201", "x-ms-request-server-encrypted" : "true", - "Date" : "Mon, 20 Apr 2020 22:10:02 GMT", + "Date" : "Fri, 21 Aug 2020 17:27:40 GMT", "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", - "ETag" : "0x8D7E57793277E64", + "ETag" : "0x8D845F78206A001", "Content-Length" : "0", - "x-ms-request-id" : "f168ae75-401e-0065-2160-17e3e4000000", - "x-ms-client-request-id" : "e6156bcf-999f-4776-83b7-7460e125cd31" + "x-ms-request-id" : "8d8ee557-101e-003d-4be0-7753b2000000", + "x-ms-client-request-id" : "f9c5a876-8940-46a1-8760-9ad227d60755" }, "Exception" : null }, { "Method" : "PUT", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcgetpropertiesdefault030262521e16065bfa4f74b/javablobgetpropertiesdefault1226465f6b058a8a404f?comp=tags", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcgetpropertiesdefault00216945021d79e5a04cc7a/javablobgetpropertiesdefault130243c9ea2682cd5e46?comp=tags", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "7aa15b38-3287-4e74-9078-47544f1efc14", + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "83a44bfc-f908-4d66-ac9b-ead5d22f96af", "Content-Type" : "application/xml; charset=utf-8" }, "Response" : { - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "retry-after" : "0", "StatusCode" : "204", - "x-ms-request-id" : "4a81e55b-101e-0068-4560-172b30000000", - "Date" : "Mon, 20 Apr 2020 22:10:03 GMT", - "x-ms-client-request-id" : "7aa15b38-3287-4e74-9078-47544f1efc14" + "x-ms-request-id" : "8d8ee560-101e-003d-50e0-7753b2000000", + "Date" : "Fri, 21 Aug 2020 17:27:40 GMT", + "x-ms-client-request-id" : "83a44bfc-f908-4d66-ac9b-ead5d22f96af" }, "Exception" : null }, { "Method" : "HEAD", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcgetpropertiesdefault030262521e16065bfa4f74b/javablobgetpropertiesdefault1226465f6b058a8a404f", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcgetpropertiesdefault00216945021d79e5a04cc7a/javablobgetpropertiesdefault130243c9ea2682cd5e46", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "59c9d805-dab1-415c-968f-cdbab121091c" + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "4bf7aa41-eef8-4970-8c32-29c83e07fddb" }, "Response" : { "x-ms-is-current-version" : "true", - "x-ms-version" : "2019-12-12", + "x-ms-last-access-time" : "Fri, 21 Aug 2020 17:27:41 GMT", + "x-ms-version" : "2020-02-10", "x-ms-lease-status" : "unlocked", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "x-ms-tag-count" : "1", "x-ms-lease-state" : "available", - "x-ms-version-id" : "2020-04-20T22:10:02.8922468Z", - "Last-Modified" : "Mon, 20 Apr 2020 22:10:02 GMT", + "x-ms-version-id" : "2020-08-21T17:27:41.3636097Z", + "Last-Modified" : "Fri, 21 Aug 2020 17:27:41 GMT", "retry-after" : "0", "StatusCode" : "200", - "Date" : "Mon, 20 Apr 2020 22:10:03 GMT", + "Date" : "Fri, 21 Aug 2020 17:27:40 GMT", "x-ms-blob-type" : "BlockBlob", "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", "Accept-Ranges" : "bytes", "x-ms-server-encrypted" : "true", "x-ms-access-tier-inferred" : "true", "x-ms-access-tier" : "Hot", - "ETag" : "0x8D7E57793277E64", - "x-ms-creation-time" : "Mon, 20 Apr 2020 22:10:02 GMT", + "ETag" : "0x8D845F78206A001", + "x-ms-creation-time" : "Fri, 21 Aug 2020 17:27:41 GMT", "Content-Length" : "7", - "x-ms-request-id" : "5f8d367a-e01e-000e-1c60-176410000000", - "x-ms-client-request-id" : "59c9d805-dab1-415c-968f-cdbab121091c", + "x-ms-request-id" : "8d8ee561-101e-003d-51e0-7753b2000000", + "x-ms-client-request-id" : "4bf7aa41-eef8-4970-8c32-29c83e07fddb", "Content-Type" : "application/octet-stream" }, "Exception" : null }, { "Method" : "GET", - "Uri" : "https://blobindex1.blob.core.windows.net?prefix=jtcgetpropertiesdefault&comp=list", + "Uri" : "https://REDACTED.blob.core.windows.net?prefix=jtcgetpropertiesdefault&comp=list", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "6940c890-26da-43f4-af58-bbdf1dbf9992" + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e795a187-a274-4583-b9d2-537d75a153fc" }, "Response" : { "Transfer-Encoding" : "chunked", - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "retry-after" : "0", "StatusCode" : "200", - "x-ms-request-id" : "f31bdb94-b01e-003c-3460-176467000000", - "Body" : "jtcgetpropertiesdefaultjtcgetpropertiesdefault030262521e16065bfa4f74bMon, 20 Apr 2020 22:10:02 GMT\"0x8D7E57792D86E2A\"unlockedavailable$account-encryption-keyfalsefalsefalse", - "Date" : "Mon, 20 Apr 2020 22:10:03 GMT", - "x-ms-client-request-id" : "6940c890-26da-43f4-af58-bbdf1dbf9992", + "x-ms-request-id" : "8d8ee562-101e-003d-52e0-7753b2000000", + "Body" : "jtcgetpropertiesdefaultjtcgetpropertiesdefault00216945021d79e5a04cc7aFri, 21 Aug 2020 17:27:40 GMT\"0x8D845F781BC4409\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Fri, 21 Aug 2020 17:27:40 GMT", + "x-ms-client-request-id" : "e795a187-a274-4583-b9d2-537d75a153fc", "Content-Type" : "application/xml" }, "Exception" : null }, { "Method" : "DELETE", - "Uri" : "https://blobindex1.blob.core.windows.net/jtcgetpropertiesdefault030262521e16065bfa4f74b?restype=container", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcgetpropertiesdefault00216945021d79e5a04cc7a?restype=container", "Headers" : { - "x-ms-version" : "2019-12-12", - "User-Agent" : "azsdk-java-azure-storage-blob/12.7.0-beta.1 (11.0.6; Windows 10 10.0)", - "x-ms-client-request-id" : "509e4f17-a48b-4b3c-87b1-3dfd6795fda2" + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "9e5a0d9b-6f08-4903-a320-abdd81e59b58" }, "Response" : { - "x-ms-version" : "2019-12-12", + "x-ms-version" : "2020-02-10", "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "retry-after" : "0", "Content-Length" : "0", "StatusCode" : "202", - "x-ms-request-id" : "998ed26e-201e-0097-7860-171bad000000", - "Date" : "Mon, 20 Apr 2020 22:10:04 GMT", - "x-ms-client-request-id" : "509e4f17-a48b-4b3c-87b1-3dfd6795fda2" + "x-ms-request-id" : "8d8ee564-101e-003d-54e0-7753b2000000", + "Date" : "Fri, 21 Aug 2020 17:27:41 GMT", + "x-ms-client-request-id" : "9e5a0d9b-6f08-4903-a320-abdd81e59b58" }, "Exception" : null } ], - "variables" : [ "jtcgetpropertiesdefault030262521e16065bfa4f74b", "javablobgetpropertiesdefault1226465f6b058a8a404f" ] + "variables" : [ "jtcgetpropertiesdefault00216945021d79e5a04cc7a", "javablobgetpropertiesdefault130243c9ea2682cd5e46" ] } \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ContainerAPITestlistblobsflatoptionslastaccesstime.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ContainerAPITestlistblobsflatoptionslastaccesstime.json new file mode 100644 index 0000000000000..2868c3b5c6346 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ContainerAPITestlistblobsflatoptionslastaccesstime.json @@ -0,0 +1,112 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/jtclistblobsflatoptionslastaccesstime015276956da3b02e?restype=container", + "Headers" : { + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "4f588fa5-41b2-45c4-92f2-40cf0d07e288" + }, + "Response" : { + "x-ms-version" : "2020-02-10", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D846051D9BC0D0", + "Last-Modified" : "Fri, 21 Aug 2020 19:05:05 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "89f54e30-f01e-0047-19ed-774ef2000000", + "Date" : "Fri, 21 Aug 2020 19:05:04 GMT", + "x-ms-client-request-id" : "4f588fa5-41b2-45c4-92f2-40cf0d07e288" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/jtclistblobsflatoptionslastaccesstime015276956da3b02e/javabloblistblobsflatoptionslastaccesstime1420350ea237f", + "Headers" : { + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "6714f752-2b2d-4cd8-be6b-9c72aa2956a3", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "x-ms-version" : "2020-02-10", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "x-ms-version-id" : "2020-08-21T19:05:06.2209026Z", + "Last-Modified" : "Fri, 21 Aug 2020 19:05:06 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Fri, 21 Aug 2020 19:05:05 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "ETag" : "0x8D846051DD51202", + "Content-Length" : "0", + "x-ms-request-id" : "89f54e49-f01e-0047-27ed-774ef2000000", + "x-ms-client-request-id" : "6714f752-2b2d-4cd8-be6b-9c72aa2956a3" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net/jtclistblobsflatoptionslastaccesstime015276956da3b02e?restype=container&comp=list", + "Headers" : { + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "3a009fd6-dbe6-40d6-aa6f-8834460a560d" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2020-02-10", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "89f54e4f-f01e-0047-2ded-774ef2000000", + "Body" : "javabloblistblobsflatoptionslastaccesstime1420350ea237f2020-08-21T19:05:06.2209026ZtrueFri, 21 Aug 2020 19:05:06 GMTFri, 21 Aug 2020 19:05:06 GMT0x8D846051DD512027application/octet-streamwh+Wm18D0z1D4E+PE252gg==Fri, 21 Aug 2020 19:05:06 GMTBlockBlobHottrueunlockedavailabletrue", + "Date" : "Fri, 21 Aug 2020 19:05:05 GMT", + "x-ms-client-request-id" : "3a009fd6-dbe6-40d6-aa6f-8834460a560d", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net?prefix=jtclistblobsflatoptionslastaccesstime&comp=list", + "Headers" : { + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "1664ee5a-1f0f-4599-8068-603398333e8c" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2020-02-10", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "89f54e62-f01e-0047-3fed-774ef2000000", + "Body" : "jtclistblobsflatoptionslastaccesstimejtclistblobsflatoptionslastaccesstime015276956da3b02eFri, 21 Aug 2020 19:05:05 GMT\"0x8D846051D9BC0D0\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Fri, 21 Aug 2020 19:05:05 GMT", + "x-ms-client-request-id" : "1664ee5a-1f0f-4599-8068-603398333e8c", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://REDACTED.blob.core.windows.net/jtclistblobsflatoptionslastaccesstime015276956da3b02e?restype=container", + "Headers" : { + "x-ms-version" : "2020-02-10", + "User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "0949fdbe-f4f6-46d6-af52-b8cf55a67dc7" + }, + "Response" : { + "x-ms-version" : "2020-02-10", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "89f54e73-f01e-0047-4ded-774ef2000000", + "Date" : "Fri, 21 Aug 2020 19:05:06 GMT", + "x-ms-client-request-id" : "0949fdbe-f4f6-46d6-af52-b8cf55a67dc7" + }, + "Exception" : null + } ], + "variables" : [ "jtclistblobsflatoptionslastaccesstime015276956da3b02e", "javabloblistblobsflatoptionslastaccesstime1420350ea237f" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/swagger/README.md b/sdk/storage/azure-storage-blob/swagger/README.md index e3d997eed8f37..a152c5b1f55b0 100644 --- a/sdk/storage/azure-storage-blob/swagger/README.md +++ b/sdk/storage/azure-storage-blob/swagger/README.md @@ -15,7 +15,7 @@ autorest --use=@microsoft.azure/autorest.java@3.0.4 --use=jianghaolu/autorest.mo ### Code generation settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/storage-dataplane-preview/specification/storage/data-plane/Microsoft.BlobStorage/preview/2019-12-12/blob.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0ba8e97726c74c2552e288591503a7e21bf3e224/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-02-10/blob.json java: true output-folder: ../ namespace: com.azure.storage.blob From c90f9b318e9280294d6273d84b97b94c51ea32d1 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Fri, 28 Aug 2020 14:15:47 -0700 Subject: [PATCH 2/2] Fixed build --- .../com/azure/storage/blob/specialized/BlobInputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java index ab18822f2a41a..33c2e6f0273d5 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobInputStream.java @@ -118,7 +118,7 @@ private static BlobProperties buildBlobProperties(BlobDownloadHeaders hd) { hd.getEncryptionKeySha256(), hd.getEncryptionScope(), null, hd.getMetadata(), hd.getBlobCommittedBlockCount(), hd.getTagCount(), hd.getVersionId(), null, hd.getObjectReplicationSourcePolicies(), hd.getObjectReplicationDestinationPolicyId(), null, - hd.isSealed(), null); + hd.isSealed(), hd.getLastAccessedTime(), null); } /**