Skip to content

Commit 8914c0e

Browse files
authored
Added constructors for DataLakePAthScheduleDeletionOptions (Azure#29070)
1 parent 79fddcf commit 8914c0e

File tree

4 files changed

+33
-21
lines changed

4 files changed

+33
-21
lines changed

sdk/storage/Azure.Storage.Files.DataLake/api/Azure.Storage.Files.DataLake.netstandard2.0.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,10 @@ public DataLakePathCreateOptions() { }
634634
}
635635
public partial class DataLakePathScheduleDeletionOptions
636636
{
637-
public DataLakePathScheduleDeletionOptions() { }
638-
public System.DateTimeOffset? ExpiresOn { get { throw null; } set { } }
639-
public System.TimeSpan? TimeToExpire { get { throw null; } set { } }
637+
public DataLakePathScheduleDeletionOptions(System.DateTimeOffset? expiresOn) { }
638+
public DataLakePathScheduleDeletionOptions(System.TimeSpan? timeToExpire) { }
639+
public System.DateTimeOffset? ExpiresOn { get { throw null; } }
640+
public System.TimeSpan? TimeToExpire { get { throw null; } }
640641
}
641642
public partial class DataLakeQueryArrowField
642643
{

sdk/storage/Azure.Storage.Files.DataLake/src/Models/DataLakePathScheduleDeletionOptions.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class DataLakePathScheduleDeletionOptions
1515
/// Does not apply to directories.
1616
/// <see cref="TimeToExpire"/> and <see cref="ExpiresOn"/> cannot both be set.
1717
/// </summary>
18-
public TimeSpan? TimeToExpire { get; set; }
18+
public TimeSpan? TimeToExpire { get; private set; }
1919

2020
/// <summary>
2121
/// The <see cref="DateTimeOffset"/> to set for when
@@ -24,6 +24,29 @@ public class DataLakePathScheduleDeletionOptions
2424
/// Does not apply to directories.
2525
/// <see cref="ExpiresOn"/> and <see cref="TimeToExpire"/> cannot both be set.
2626
/// </summary>
27-
public DateTimeOffset? ExpiresOn { get; set; }
27+
public DateTimeOffset? ExpiresOn { get; private set; }
28+
29+
/// <summary>
30+
/// Constructor. Sets the <see cref="DateTimeOffset"/> when the path will
31+
/// be deleted.
32+
/// </summary>
33+
/// <param name="expiresOn">
34+
/// The DateTimeOffset when the file will be deleted.
35+
/// </param>
36+
public DataLakePathScheduleDeletionOptions(DateTimeOffset? expiresOn)
37+
{
38+
ExpiresOn = expiresOn;
39+
}
40+
41+
/// <summary>
42+
/// Constructor. Sets time when the path will be deleted, relative to the current time.
43+
/// </summary>
44+
/// <param name="timeToExpire">
45+
/// Duration before path will be deleted.
46+
/// </param>
47+
public DataLakePathScheduleDeletionOptions(TimeSpan? timeToExpire)
48+
{
49+
TimeToExpire = timeToExpire;
50+
}
2851
}
2952
}

sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,7 @@ public async Task CreateAsync_TimeToExpire(bool createIfNotExists)
546546

547547
DataLakePathCreateOptions options = new DataLakePathCreateOptions
548548
{
549-
ScheduleDeletionOptions = new DataLakePathScheduleDeletionOptions
550-
{
551-
TimeToExpire = new TimeSpan(5, 5, 5)
552-
}
549+
ScheduleDeletionOptions = new DataLakePathScheduleDeletionOptions(timeToExpire: new TimeSpan(5, 5, 5))
553550
};
554551

555552
// Act
@@ -582,10 +579,7 @@ public async Task CreateAsync_ExpiresOn(bool createIfNotExists)
582579

583580
DataLakePathCreateOptions options = new DataLakePathCreateOptions
584581
{
585-
ScheduleDeletionOptions = new DataLakePathScheduleDeletionOptions
586-
{
587-
ExpiresOn = Recording.UtcNow
588-
}
582+
ScheduleDeletionOptions = new DataLakePathScheduleDeletionOptions(expiresOn: Recording.UtcNow)
589583
};
590584

591585
// Act

sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,7 @@ public async Task CreateAsync_RelativeExpiry(bool createIfNotExists)
529529

530530
DataLakePathCreateOptions options = new DataLakePathCreateOptions
531531
{
532-
ScheduleDeletionOptions = new DataLakePathScheduleDeletionOptions
533-
{
534-
TimeToExpire = new TimeSpan(hours: 1, minutes: 0, seconds: 0)
535-
}
532+
ScheduleDeletionOptions = new DataLakePathScheduleDeletionOptions(timeToExpire: new TimeSpan(hours: 1, minutes: 0, seconds: 0))
536533
};
537534

538535
// Act
@@ -562,10 +559,7 @@ public async Task CreateAsync_AbsoluteExpiry(bool createIfNotExists)
562559

563560
DataLakePathCreateOptions options = new DataLakePathCreateOptions
564561
{
565-
ScheduleDeletionOptions = new DataLakePathScheduleDeletionOptions
566-
{
567-
ExpiresOn = new DateTimeOffset(2100, 1, 1, 0, 0, 0, 0, TimeSpan.Zero)
568-
}
562+
ScheduleDeletionOptions = new DataLakePathScheduleDeletionOptions(expiresOn: new DateTimeOffset(2100, 1, 1, 0, 0, 0, 0, TimeSpan.Zero))
569563
};
570564

571565
// Act

0 commit comments

Comments
 (0)