Skip to content

Commit 12ccb88

Browse files
adding enableSmbDirectoryLease property (#46362)
* adding enableSmbDirectoryLease property * adding tests * fixing linting errors
1 parent cc160b5 commit 12ccb88

File tree

13 files changed

+461
-51
lines changed

13 files changed

+461
-51
lines changed

sdk/storage/azure-storage-file-share/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/storage/azure-storage-file-share",
5-
"Tag": "java/storage/azure-storage-file-share_bf4bf2f437"
5+
"Tag": "java/storage/azure-storage-file-share_e7a870d29a"
66
}

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareAsyncClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ public Mono<Response<ShareInfo>> createWithResponse(ShareCreateOptions options)
361361
}
362362

363363
Mono<Response<ShareInfo>> createWithResponse(ShareCreateOptions options, Context context) {
364-
context = context == null ? Context.NONE : context;
365364
options = options == null ? new ShareCreateOptions() : options;
366365
String enabledProtocol = options.getProtocols() == null ? null : options.getProtocols().toString();
367366
enabledProtocol = "".equals(enabledProtocol) ? null : enabledProtocol;
@@ -370,7 +369,8 @@ Mono<Response<ShareInfo>> createWithResponse(ShareCreateOptions options, Context
370369
options.getAccessTier(), enabledProtocol, options.getRootSquash(),
371370
options.isSnapshotVirtualDirectoryAccessEnabled(), options.isPaidBurstingEnabled(),
372371
options.getPaidBurstingMaxBandwidthMibps(), options.getPaidBurstingMaxIops(),
373-
options.getProvisionedMaxIops(), options.getProvisionedMaxBandwidthMibps(), context)
372+
options.getProvisionedMaxIops(), options.getProvisionedMaxBandwidthMibps(),
373+
options.isEnableSmbDirectoryLease())
374374
.map(ModelHelper::mapToShareInfoResponse);
375375
}
376376

@@ -933,13 +933,13 @@ Mono<Response<ShareInfo>> setPropertiesWithResponse(ShareSetPropertiesOptions op
933933
StorageImplUtils.assertNotNull("options", options);
934934
ShareRequestConditions requestConditions
935935
= options.getRequestConditions() == null ? new ShareRequestConditions() : options.getRequestConditions();
936-
context = context == null ? Context.NONE : context;
937936
return azureFileStorageClient.getShares()
938937
.setPropertiesNoCustomHeadersWithResponseAsync(shareName, null, options.getQuotaInGb(),
939938
options.getAccessTier(), requestConditions.getLeaseId(), options.getRootSquash(),
940939
options.isSnapshotVirtualDirectoryAccessEnabled(), options.isPaidBurstingEnabled(),
941940
options.getPaidBurstingMaxBandwidthMibps(), options.getPaidBurstingMaxIops(),
942-
options.getProvisionedMaxIops(), options.getProvisionedMaxBandwidthMibps(), context)
941+
options.getProvisionedMaxIops(), options.getProvisionedMaxBandwidthMibps(),
942+
options.isEnableSmbDirectoryLease())
943943
.map(ModelHelper::mapToShareInfoResponse);
944944
}
945945

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ public Response<ShareInfo> createWithResponse(ShareCreateOptions options, Durati
367367
finalOptions.getAccessTier(), finalEnabledProtocol, finalOptions.getRootSquash(),
368368
finalOptions.isSnapshotVirtualDirectoryAccessEnabled(), finalOptions.isPaidBurstingEnabled(),
369369
finalOptions.getPaidBurstingMaxBandwidthMibps(), finalOptions.getPaidBurstingMaxIops(),
370-
finalOptions.getProvisionedMaxIops(), finalOptions.getProvisionedMaxBandwidthMibps(), finalContext);
370+
finalOptions.getProvisionedMaxIops(), finalOptions.getProvisionedMaxBandwidthMibps(),
371+
finalOptions.isEnableSmbDirectoryLease(), finalContext);
371372

372373
return ModelHelper.mapToShareInfoResponse(sendRequest(operation, timeout, ShareStorageException.class));
373374
}
@@ -897,7 +898,8 @@ public Response<ShareInfo> setPropertiesWithResponse(ShareSetPropertiesOptions o
897898
requestConditions.getLeaseId(), options.getRootSquash(),
898899
options.isSnapshotVirtualDirectoryAccessEnabled(), options.isPaidBurstingEnabled(),
899900
options.getPaidBurstingMaxBandwidthMibps(), options.getPaidBurstingMaxIops(),
900-
options.getProvisionedMaxIops(), options.getProvisionedMaxBandwidthMibps(), finalContext);
901+
options.getProvisionedMaxIops(), options.getProvisionedMaxBandwidthMibps(),
902+
options.isEnableSmbDirectoryLease(), finalContext);
901903

902904
return ModelHelper.mapToShareInfoResponse(sendRequest(operation, timeout, ShareStorageException.class));
903905
}

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/SharesImpl.java

Lines changed: 134 additions & 42 deletions
Large diffs are not rendered by default.

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharePropertiesInternal.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ public final class SharePropertiesInternal implements XmlSerializable<SharePrope
183183
@Generated
184184
private DateTimeRfc1123 nextAllowedProvisionedBandwidthDowngradeTime;
185185

186+
/*
187+
* The EnableSmbDirectoryLease property.
188+
*/
189+
@Generated
190+
private Boolean enableSmbDirectoryLease;
191+
186192
/*
187193
* Dictionary of <string>
188194
*/
@@ -819,6 +825,28 @@ public OffsetDateTime getNextAllowedProvisionedBandwidthDowngradeTime() {
819825
return this;
820826
}
821827

828+
/**
829+
* Get the enableSmbDirectoryLease property: The EnableSmbDirectoryLease property.
830+
*
831+
* @return the enableSmbDirectoryLease value.
832+
*/
833+
@Generated
834+
public Boolean isEnableSmbDirectoryLease() {
835+
return this.enableSmbDirectoryLease;
836+
}
837+
838+
/**
839+
* Set the enableSmbDirectoryLease property: The EnableSmbDirectoryLease property.
840+
*
841+
* @param enableSmbDirectoryLease the enableSmbDirectoryLease value to set.
842+
* @return the SharePropertiesInternal object itself.
843+
*/
844+
@Generated
845+
public SharePropertiesInternal setEnableSmbDirectoryLease(Boolean enableSmbDirectoryLease) {
846+
this.enableSmbDirectoryLease = enableSmbDirectoryLease;
847+
return this;
848+
}
849+
822850
/**
823851
* Get the metadata property: Dictionary of &lt;string&gt;.
824852
*
@@ -884,6 +912,7 @@ public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLSt
884912
Objects.toString(this.nextAllowedProvisionedIopsDowngradeTime, null));
885913
xmlWriter.writeStringElement("NextAllowedProvisionedBandwidthDowngradeTime",
886914
Objects.toString(this.nextAllowedProvisionedBandwidthDowngradeTime, null));
915+
xmlWriter.writeBooleanElement("EnableSmbDirectoryLease", this.enableSmbDirectoryLease);
887916
if (this.metadata != null) {
888917
xmlWriter.writeStartElement("Metadata");
889918
for (Map.Entry<String, String> entry : this.metadata.entrySet()) {
@@ -996,6 +1025,9 @@ public static SharePropertiesInternal fromXml(XmlReader xmlReader, String rootEl
9961025
} else if ("NextAllowedProvisionedBandwidthDowngradeTime".equals(elementName.getLocalPart())) {
9971026
deserializedSharePropertiesInternal.nextAllowedProvisionedBandwidthDowngradeTime
9981027
= reader.getNullableElement(DateTimeRfc1123::new);
1028+
} else if ("EnableSmbDirectoryLease".equals(elementName.getLocalPart())) {
1029+
deserializedSharePropertiesInternal.enableSmbDirectoryLease
1030+
= reader.getNullableElement(Boolean::parseBoolean);
9991031
} else if ("Metadata".equals(elementName.getLocalPart())) {
10001032
while (reader.nextElement() != XmlToken.END_ELEMENT) {
10011033
if (deserializedSharePropertiesInternal.metadata == null) {

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharesGetPropertiesHeaders.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ public final class SharesGetPropertiesHeaders {
106106
@Generated
107107
private LeaseDurationType xMsLeaseDuration;
108108

109+
/*
110+
* The x-ms-enable-smb-directory-lease property.
111+
*/
112+
@Generated
113+
private Boolean xMsEnableSmbDirectoryLease;
114+
109115
/*
110116
* The x-ms-request-id property.
111117
*/
@@ -223,6 +229,9 @@ public final class SharesGetPropertiesHeaders {
223229

224230
private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration");
225231

232+
private static final HttpHeaderName X_MS_ENABLE_SMB_DIRECTORY_LEASE
233+
= HttpHeaderName.fromString("x-ms-enable-smb-directory-lease");
234+
226235
private static final HttpHeaderName X_MS_ACCESS_TIER_TRANSITION_STATE
227236
= HttpHeaderName.fromString("x-ms-access-tier-transition-state");
228237

@@ -333,6 +342,12 @@ public SharesGetPropertiesHeaders(HttpHeaders rawHeaders) {
333342
} else {
334343
this.xMsLeaseDuration = null;
335344
}
345+
String xMsEnableSmbDirectoryLease = rawHeaders.getValue(X_MS_ENABLE_SMB_DIRECTORY_LEASE);
346+
if (xMsEnableSmbDirectoryLease != null) {
347+
this.xMsEnableSmbDirectoryLease = Boolean.parseBoolean(xMsEnableSmbDirectoryLease);
348+
} else {
349+
this.xMsEnableSmbDirectoryLease = null;
350+
}
336351
this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID);
337352
this.xMsAccessTierTransitionState = rawHeaders.getValue(X_MS_ACCESS_TIER_TRANSITION_STATE);
338353
String xMsShareNextAllowedQuotaDowngradeTime
@@ -734,6 +749,28 @@ public SharesGetPropertiesHeaders setXMsLeaseDuration(LeaseDurationType xMsLease
734749
return this;
735750
}
736751

752+
/**
753+
* Get the xMsEnableSmbDirectoryLease property: The x-ms-enable-smb-directory-lease property.
754+
*
755+
* @return the xMsEnableSmbDirectoryLease value.
756+
*/
757+
@Generated
758+
public Boolean isXMsEnableSmbDirectoryLease() {
759+
return this.xMsEnableSmbDirectoryLease;
760+
}
761+
762+
/**
763+
* Set the xMsEnableSmbDirectoryLease property: The x-ms-enable-smb-directory-lease property.
764+
*
765+
* @param xMsEnableSmbDirectoryLease the xMsEnableSmbDirectoryLease value to set.
766+
* @return the SharesGetPropertiesHeaders object itself.
767+
*/
768+
@Generated
769+
public SharesGetPropertiesHeaders setXMsEnableSmbDirectoryLease(Boolean xMsEnableSmbDirectoryLease) {
770+
this.xMsEnableSmbDirectoryLease = xMsEnableSmbDirectoryLease;
771+
return this;
772+
}
773+
737774
/**
738775
* Get the xMsRequestId property: The x-ms-request-id property.
739776
*

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/ModelHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ public static ShareProperties populateShareProperties(SharePropertiesInternal sh
238238
sharePropertiesInternal.getNextAllowedProvisionedIopsDowngradeTime());
239239
properties.setNextAllowedProvisionedBandwidthDowngradeTime(
240240
sharePropertiesInternal.getNextAllowedProvisionedBandwidthDowngradeTime());
241+
properties.setEnableSmbDirectoryLease(sharePropertiesInternal.isEnableSmbDirectoryLease());
241242

242243
return properties;
243244
}
@@ -517,7 +518,8 @@ public static Response<ShareInfo> mapToShareInfoResponse(Response<?> response) {
517518
.setMaxBurstCreditsForIops(headers.getXMsShareMaxBurstCreditsForIops())
518519
.setNextAllowedProvisionedIopsDowngradeTime(headers.getXMsShareNextAllowedProvisionedIopsDowngradeTime())
519520
.setNextAllowedProvisionedBandwidthDowngradeTime(
520-
headers.getXMsShareNextAllowedProvisionedBandwidthDowngradeTime());
521+
headers.getXMsShareNextAllowedProvisionedBandwidthDowngradeTime())
522+
.setEnableSmbDirectoryLease(headers.isXMsEnableSmbDirectoryLease());
521523

522524
return new SimpleResponse<>(response, shareProperties);
523525
}

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareProperties.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ public final class ShareProperties implements XmlSerializable<ShareProperties> {
162162
*/
163163
private OffsetDateTime nextAllowedProvisionedBandwidthDowngradeTime;
164164

165+
/*
166+
* Optional, default value is true. Only applicable to SMB shares.
167+
* Specifies whether granting of new directory leases for directories present in a share are to be enabled or disabled.
168+
*/
169+
private Boolean enableSmbDirectoryLease;
170+
165171
/**
166172
* Creates a new instance of {@link ShareProperties}.
167173
*/
@@ -796,6 +802,30 @@ public OffsetDateTime getNextAllowedProvisionedBandwidthDowngradeTime() {
796802
return this;
797803
}
798804

805+
/**
806+
* Optional, default value is true. Only applicable to SMB shares.
807+
* Specifies whether granting of new directory leases for directories present in a share are to be enabled or disabled.
808+
* An input of true specifies that granting of new directory leases is to be allowed.
809+
* An input of false specifies that granting of new directory leases is to be blocked.
810+
* @return the enableSmbDirectoryLease value.
811+
*/
812+
public Boolean isEnableSmbDirectoryLease() {
813+
return enableSmbDirectoryLease;
814+
}
815+
816+
/**
817+
* Optional, default value is true. Only applicable to SMB shares.
818+
* Specifies whether granting of new directory leases for directories present in a share are to be enabled or disabled.
819+
* An input of true specifies that granting of new directory leases is to be allowed.
820+
* An input of false specifies that granting of new directory leases is to be blocked.
821+
* @param enableSmbDirectoryLease the enableSmbDirectoryLease value to set.
822+
* @return the ShareProperties object itself.
823+
*/
824+
public ShareProperties setEnableSmbDirectoryLease(Boolean enableSmbDirectoryLease) {
825+
this.enableSmbDirectoryLease = enableSmbDirectoryLease;
826+
return this;
827+
}
828+
799829
@Override
800830
public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException {
801831
return toXml(xmlWriter, null);

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareCreateOptions.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class ShareCreateOptions {
2626
private Long paidBurstingMaxBandwidthMibps;
2727
private Long provisionedMaxIops;
2828
private Long provisionedMaxBandwidthMibps;
29+
private Boolean enableSmbDirectoryLease;
2930

3031
/**
3132
* Creates a new instance of {@link ShareCreateOptions}.
@@ -277,4 +278,28 @@ public ShareCreateOptions setProvisionedMaxBandwidthMibps(Long provisionedMaxBan
277278
this.provisionedMaxBandwidthMibps = provisionedMaxBandwidthMibps;
278279
return this;
279280
}
281+
282+
/**
283+
* Optional, default value is true. Only applicable to SMB shares.
284+
* Specifies whether granting of new directory leases for directories present in a share are to be enabled or disabled.
285+
* An input of true specifies that granting of new directory leases is to be allowed.
286+
* An input of false specifies that granting of new directory leases is to be blocked.
287+
* @return the enableSmbDirectoryLease value.
288+
*/
289+
public Boolean isEnableSmbDirectoryLease() {
290+
return enableSmbDirectoryLease;
291+
}
292+
293+
/**
294+
* Optional, default value is true. Only applicable to SMB shares.
295+
* Specifies whether granting of new directory leases for directories present in a share are to be enabled or disabled.
296+
* An input of true specifies that granting of new directory leases is to be allowed.
297+
* An input of false specifies that granting of new directory leases is to be blocked.
298+
* @param enableSmbDirectoryLease the enableSmbDirectoryLease value to set.
299+
* @return the ShareCreateOptions object itself.
300+
*/
301+
public ShareCreateOptions setEnableSmbDirectoryLease(Boolean enableSmbDirectoryLease) {
302+
this.enableSmbDirectoryLease = enableSmbDirectoryLease;
303+
return this;
304+
}
280305
}

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareSetPropertiesOptions.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class ShareSetPropertiesOptions {
2323
private Long paidBurstingMaxBandwidthMibps;
2424
private Long provisionedMaxIops;
2525
private Long provisionedMaxBandwidthMibps;
26+
private Boolean enableSmbDirectoryLease;
2627

2728
/**
2829
* Creates a new instance of {@link ShareSetPropertiesOptions}.
@@ -256,4 +257,28 @@ public ShareSetPropertiesOptions setProvisionedMaxBandwidthMibps(Long provisione
256257
this.provisionedMaxBandwidthMibps = provisionedMaxBandwidthMibps;
257258
return this;
258259
}
260+
261+
/**
262+
* Optional, default value is true. Only applicable to SMB shares.
263+
* Specifies whether granting of new directory leases for directories present in a share are to be enabled or disabled.
264+
* An input of true specifies that granting of new directory leases is to be allowed.
265+
* An input of false specifies that granting of new directory leases is to be blocked.
266+
* @return the enableSmbDirectoryLease value.
267+
*/
268+
public Boolean isEnableSmbDirectoryLease() {
269+
return enableSmbDirectoryLease;
270+
}
271+
272+
/**
273+
* Optional, default value is true. Only applicable to SMB shares.
274+
* Specifies whether granting of new directory leases for directories present in a share are to be enabled or disabled.
275+
* An input of true specifies that granting of new directory leases is to be allowed.
276+
* An input of false specifies that granting of new directory leases is to be blocked.
277+
* @param enableSmbDirectoryLease the enableSmbDirectoryLease value to set.
278+
* @return the ShareSetPropertiesOptions object itself.
279+
*/
280+
public ShareSetPropertiesOptions setEnableSmbDirectoryLease(Boolean enableSmbDirectoryLease) {
281+
this.enableSmbDirectoryLease = enableSmbDirectoryLease;
282+
return this;
283+
}
259284
}

0 commit comments

Comments
 (0)