Skip to content

Commit

Permalink
Implement StartOffset and EndOffset in ListObjectsOptions
Browse files Browse the repository at this point in the history
Fixes #4993.
  • Loading branch information
jskeet committed May 28, 2020
1 parent db4f9a9 commit fbcca00
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public void ModifyRequest_DefaultOptions()
Assert.Null(request.Versions);
Assert.Null(request.UserProject);
Assert.Null(request.PageToken);
Assert.Null(request.StartOffset);
Assert.Null(request.EndOffset);
}

[Fact]
Expand All @@ -48,7 +50,9 @@ public void ModifyRequest_AllOptions()
Versions = true,
UserProject = "proj",
PageToken = "nextpage",
Fields = "items(name),nextPageToken"
Fields = "items(name),nextPageToken",
StartOffset = "start",
EndOffset = "end"
};
options.ModifyRequest(request);
Assert.Equal(10, request.MaxResults);
Expand All @@ -59,6 +63,8 @@ public void ModifyRequest_AllOptions()
Assert.Equal("proj", request.UserProject);
Assert.Equal("nextpage", request.PageToken);
Assert.Equal("items(name),nextPageToken", request.Fields);
Assert.Equal("start", request.StartOffset);
Assert.Equal("end", request.EndOffset);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ public sealed class ListObjectsOptions
/// </summary>
public string Fields { get; set; }

/// <summary>
/// If set, filters results to objects whose names are lexicographically equal to or after
/// this value. (Objects whose names are exactly the start offset are included.)
/// </summary>
public string StartOffset { get; set; }

/// <summary>
/// If set, filters results to objects whose names are lexicographically before
/// this value. (Objects whose names are exactly the end offset are excluded.)
/// </summary>
public string EndOffset { get; set; }

/// <summary>
/// Modifies the specified request for all non-null properties of this options object.
/// </summary>
Expand Down Expand Up @@ -118,6 +130,14 @@ internal void ModifyRequest(ListRequest request)
{
request.Fields = Fields;
}
if (StartOffset != null)
{
request.StartOffset = StartOffset;
}
if (EndOffset != null)
{
request.EndOffset = EndOffset;
}
}
}
}

0 comments on commit fbcca00

Please sign in to comment.