Skip to content
Open
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 @@ -8,6 +8,7 @@
import com.azure.storage.internal.avro.implementation.AvroConstants;
import com.azure.storage.internal.avro.implementation.schema.AvroSchema;

import java.time.OffsetDateTime;
import java.util.Map;
import java.util.Objects;

Expand All @@ -29,6 +30,9 @@ public class InternalBlobChangefeedEventData implements BlobChangefeedEventData
private final String blobUrl;
private final boolean recursive;
private final String sequencer;
private final OffsetDateTime creationTime;
private final OffsetDateTime lastAccessTime;
private final String restoredContainerVersion;

/**
* Constructs a {@link InternalBlobChangefeedEventData}.
Expand All @@ -46,10 +50,14 @@ public class InternalBlobChangefeedEventData implements BlobChangefeedEventData
* @param blobUrl The blob url.
* @param recursive Whether this operation was recursive.
* @param sequencer The sequencer.
* @param creationTime The blob creation time. Schema V6.
* @param lastAccessTime The last access time. Schema V7.
* @param restoredContainerVersion The restored container version. Schema V8.
*/
public InternalBlobChangefeedEventData(String api, String clientRequestId, String requestId, String eTag,
String contentType, Long contentLength, BlobType blobType, Long contentOffset, String destinationUrl,
String sourceUrl, String blobUrl, boolean recursive, String sequencer) {
String sourceUrl, String blobUrl, boolean recursive, String sequencer, OffsetDateTime creationTime,
OffsetDateTime lastAccessTime, String restoredContainerVersion) {
this.api = api;
this.clientRequestId = clientRequestId;
this.requestId = requestId;
Expand All @@ -63,6 +71,9 @@ public InternalBlobChangefeedEventData(String api, String clientRequestId, Strin
this.blobUrl = blobUrl;
this.recursive = recursive;
this.sequencer = sequencer;
this.creationTime = creationTime;
this.lastAccessTime = lastAccessTime;
this.restoredContainerVersion = restoredContainerVersion;
}

static InternalBlobChangefeedEventData fromRecord(Object d) {
Expand All @@ -86,6 +97,9 @@ static InternalBlobChangefeedEventData fromRecord(Object d) {
Object blobUrl = data.get("url");
Object recursive = data.get("recursive");
Object sequencer = data.get("sequencer");
Object createTime = data.get("createTime");
Object lastAccessTime = data.get("lastAccessTime");
Object restoredContainerVersion = data.get("restoredContainerVersion");

return new InternalBlobChangefeedEventData(ChangefeedTypeValidator.nullOr("api", api, String.class),
ChangefeedTypeValidator.nullOr("clientRequestId", clientRequestId, String.class),
Expand All @@ -101,7 +115,16 @@ static InternalBlobChangefeedEventData fromRecord(Object d) {
ChangefeedTypeValidator.nullOr("sourceUrl", sourceUrl, String.class),
ChangefeedTypeValidator.nullOr("url", blobUrl, String.class),
Boolean.TRUE.equals(ChangefeedTypeValidator.nullOr("recursive", recursive, Boolean.class)),
ChangefeedTypeValidator.nullOr("sequencer", sequencer, String.class));
ChangefeedTypeValidator.nullOr("sequencer", sequencer, String.class),
ChangefeedTypeValidator.isNull(createTime)
? null
: OffsetDateTime.parse(
Objects.requireNonNull(ChangefeedTypeValidator.nullOr("createTime", createTime, String.class))),
ChangefeedTypeValidator.isNull(lastAccessTime)
? null
: OffsetDateTime.parse(Objects
.requireNonNull(ChangefeedTypeValidator.nullOr("lastAccessTime", lastAccessTime, String.class))),
ChangefeedTypeValidator.nullOr("restoredContainerVersion", restoredContainerVersion, String.class));
}

@Override
Expand Down Expand Up @@ -169,6 +192,21 @@ public String getSequencer() {
return sequencer;
}

@Override
public OffsetDateTime getCreationTime() {
return creationTime;
}

@Override
public OffsetDateTime getLastAccessTime() {
return lastAccessTime;
}

@Override
public String getRestoredContainerVersion() {
return restoredContainerVersion;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -190,14 +228,17 @@ && getBlobType() == that.getBlobType()
&& Objects.equals(getSourceUrl(), that.getSourceUrl())
&& Objects.equals(getBlobUrl(), that.getBlobUrl())
&& Objects.equals(isRecursive(), that.isRecursive())
&& Objects.equals(getSequencer(), that.getSequencer());
&& Objects.equals(getSequencer(), that.getSequencer())
&& Objects.equals(getCreationTime(), that.getCreationTime())
&& Objects.equals(getLastAccessTime(), that.getLastAccessTime())
&& Objects.equals(getRestoredContainerVersion(), that.getRestoredContainerVersion());
}

@Override
public int hashCode() {
return Objects.hash(getApi(), getClientRequestId(), getRequestId(), getETag(), getContentType(),
getContentLength(), getBlobType(), getContentOffset(), getDestinationUrl(), getSourceUrl(), getBlobUrl(),
isRecursive(), getSequencer());
isRecursive(), getSequencer(), getCreationTime(), getLastAccessTime(), getRestoredContainerVersion());
}

@Override
Expand All @@ -206,6 +247,8 @@ public String toString() {
+ ", requestId='" + requestId + '\'' + ", eTag='" + eTag + '\'' + ", contentType='" + contentType + '\''
+ ", contentLength=" + contentLength + ", blobType=" + blobType + ", contentOffset=" + contentOffset
+ ", destinationUrl='" + destinationUrl + '\'' + ", sourceUrl='" + sourceUrl + '\'' + ", blobUrl='"
+ blobUrl + '\'' + ", recursive=" + recursive + ", sequencer='" + sequencer + '\'' + '}';
+ blobUrl + '\'' + ", recursive=" + recursive + ", sequencer='" + sequencer + '\'' + ", creationTime="
+ creationTime + ", lastAccessTime=" + lastAccessTime + ", restoredContainerVersion='"
+ restoredContainerVersion + '\'' + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import com.azure.storage.blob.models.BlobType;

import java.time.OffsetDateTime;

/**
* This class contains properties of a BlobChangefeedEventData.
*/
Expand Down Expand Up @@ -101,4 +103,31 @@ public interface BlobChangefeedEventData {
*/
String getSequencer();

/**
* Gets the blob creation time. Present in schema V6 and later for AppendBlob data-updated events.
*
* @return The creation time, or null if not present.
*/
default OffsetDateTime getCreationTime() {
return null;
}

/**
* Gets the last access time of the blob. Present in schema V7 and later.
*
* @return The last access time, or null if not present.
*/
default OffsetDateTime getLastAccessTime() {
return null;
}

/**
* Gets the restored container version. Present in schema V8 and later for RestoreContainer events.
*
* @return The restored container version, or null if not present.
*/
default String getRestoredContainerVersion() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ public final class BlobChangefeedEventType extends ExpandableStringEnum<BlobChan
*/
public static final BlobChangefeedEventType BLOB_DELETED = fromString("BlobDeleted");

/**
* Static value AppendBlobDataUpdated for BlobChangefeedEventType. Schema V6.
*/
public static final BlobChangefeedEventType APPEND_BLOB_DATA_UPDATED = fromString("AppendBlobDataUpdated");

/**
* Static value BlobLastAccessTimeUpdated for BlobChangefeedEventType. Schema V7.
*/
public static final BlobChangefeedEventType BLOB_LAST_ACCESS_TIME_UPDATED = fromString("BlobLastAccessTimeUpdated");

/**
* Static value ContainerCreated for BlobChangefeedEventType. Schema V8.
*/
public static final BlobChangefeedEventType CONTAINER_CREATED = fromString("ContainerCreated");

/**
* Static value ContainerDeleted for BlobChangefeedEventType. Schema V8.
*/
public static final BlobChangefeedEventType CONTAINER_DELETED = fromString("ContainerDeleted");

/**
* Static value ContainerPropertiesUpdated for BlobChangefeedEventType. Schema V8.
*/
public static final BlobChangefeedEventType CONTAINER_PROPERTIES_UPDATED = fromString("ContainerPropertiesUpdated");

/**
* Creates a new instance of {@link BlobChangefeedEventType} with no string value.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.storage.blob.changefeed.models;

import com.azure.core.util.ExpandableStringEnum;

import java.util.Collection;

/**
* This class represents the operation name that triggered a {@link BlobChangefeedEvent}.
*/
public final class BlobOperationName extends ExpandableStringEnum<BlobOperationName> {

/** Static value UnspecifiedApi for BlobOperationName. */
public static final BlobOperationName UNSPECIFIED_API = fromString("UnspecifiedApi");

/** Static value PutBlob for BlobOperationName. */
public static final BlobOperationName PUT_BLOB = fromString("PutBlob");

/** Static value PutBlockList for BlobOperationName. */
public static final BlobOperationName PUT_BLOCK_LIST = fromString("PutBlockList");

/** Static value CopyBlob for BlobOperationName. */
public static final BlobOperationName COPY_BLOB = fromString("CopyBlob");

/** Static value DeleteBlob for BlobOperationName. */
public static final BlobOperationName DELETE_BLOB = fromString("DeleteBlob");

/** Static value SetBlobMetadata for BlobOperationName. */
public static final BlobOperationName SET_BLOB_METADATA = fromString("SetBlobMetadata");

/** Static value ControlEvent for BlobOperationName. */
public static final BlobOperationName CONTROL_EVENT = fromString("ControlEvent");

/** Static value UndeleteBlob for BlobOperationName. */
public static final BlobOperationName UNDELETE_BLOB = fromString("UndeleteBlob");

/** Static value SetBlobProperties for BlobOperationName. */
public static final BlobOperationName SET_BLOB_PROPERTIES = fromString("SetBlobProperties");

/** Static value SnapshotBlob for BlobOperationName. */
public static final BlobOperationName SNAPSHOT_BLOB = fromString("SnapshotBlob");

/** Static value SetBlobTier for BlobOperationName. */
public static final BlobOperationName SET_BLOB_TIER = fromString("SetBlobTier");

/** Static value AbortCopyBlob for BlobOperationName. */
public static final BlobOperationName ABORT_COPY_BLOB = fromString("AbortCopyBlob");

/** Static value SetBlobTags for BlobOperationName. */
public static final BlobOperationName SET_BLOB_TAGS = fromString("SetBlobTags");

/** Static value CreateRestorePointMarker for BlobOperationName. */
public static final BlobOperationName CREATE_RESTORE_POINT_MARKER = fromString("CreateRestorePointMarker");

/** Static value AppendBlock for BlobOperationName. Schema V6. */
public static final BlobOperationName APPEND_BLOCK = fromString("AppendBlock");

/** Static value UpdateLastAccessTime for BlobOperationName. Schema V7. */
public static final BlobOperationName UPDATE_LAST_ACCESS_TIME = fromString("UpdateLastAccessTime");

/** Static value CreateContainer for BlobOperationName. Schema V8. */
public static final BlobOperationName CREATE_CONTAINER = fromString("ContainerCreated");

/** Static value DeleteContainer for BlobOperationName. Schema V8. */
public static final BlobOperationName DELETE_CONTAINER = fromString("ContainerDeleted");

/** Static value RestoreContainer for BlobOperationName. Schema V8. */
public static final BlobOperationName RESTORE_CONTAINER = fromString("RestoreContainer");

/** Static value SetContainerMetadata for BlobOperationName. Schema V8. */
public static final BlobOperationName SET_CONTAINER_METADATA = fromString("SetContainerMetadata");

/**
* Creates a new instance of {@link BlobOperationName} with no string value.
*
* @deprecated Please use {@link #fromString(String)} to create an instance of BlobOperationName.
*/
@Deprecated
public BlobOperationName() {
}

/**
* Creates or finds a BlobOperationName from its string representation.
*
* @param name a name to look for.
* @return the corresponding BlobOperationName.
*/
public static BlobOperationName fromString(String name) {
return fromString(name, BlobOperationName.class);
}

/**
* Gets known BlobOperationName values.
*
* @return known BlobOperationName values.
*/
public static Collection<BlobOperationName> values() {
return values(BlobOperationName.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ private static Map<String, Object> getMockChangefeedEventDataRecord(BlobChangefe
cfEventData.put("url", data.getBlobUrl());
cfEventData.put("sequencer", data.getSequencer());
cfEventData.put("recursive", data.isRecursive());
cfEventData.put("createTime", null);
cfEventData.put("lastAccessTime", null);
cfEventData.put("restoredContainerVersion", null);
return cfEventData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static BlobChangefeedEvent getMockBlobChangefeedEvent(int index) {
static BlobChangefeedEventData getMockBlobChangefeedEventData() {
return new InternalBlobChangefeedEventData("PutBlob", "clientRequestId", "requestId", "etag",
"application/octet-stream", 100L, BlobType.BLOCK_BLOB, 0L, "destinationUrl", "sourceUrl", "", false,
"sequencer");
"sequencer", null, null, null);
}

private MockedChangefeedResources() {
Expand Down
Loading