Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to read last access time #14342

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -346,4 +348,33 @@ public static PageBlobCopyIncrementalRequestConditions populateBlobDestinationRe
.setIfUnmodifiedSince(requestConditions.getIfUnmodifiedSince())
.setTagsConditions(null);
}

public static String getObjectReplicationDestinationPolicyId(Map<String, String> objectReplicationStatus) {
objectReplicationStatus = objectReplicationStatus == null ? new HashMap<>() : objectReplicationStatus;
return objectReplicationStatus.getOrDefault("policy-id", null);
}

public static List<ObjectReplicationPolicy> getObjectReplicationSourcePolicies(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was refactored from somewhere else?

Map<String, String> objectReplicationStatus) {
Map<String, List<ObjectReplicationRule>> internalSourcePolicies = new HashMap<>();
objectReplicationStatus = objectReplicationStatus == null ? new HashMap<>() : objectReplicationStatus;
if (getObjectReplicationDestinationPolicyId(objectReplicationStatus) == null) {
for (Map.Entry<String, String> 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<ObjectReplicationPolicy> objectReplicationSourcePolicies = new ArrayList<>();
for (Map.Entry<String, List<ObjectReplicationRule>> entry : internalSourcePolicies.entrySet()) {
objectReplicationSourcePolicies.add(new ObjectReplicationPolicy(entry.getKey(), entry.getValue()));
}
return objectReplicationSourcePolicies;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
}
Loading