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

share change deleteSnapshot from bool to enum, to support include and include-leased #119

Merged
merged 1 commit into from
Nov 21, 2024
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
17 changes: 12 additions & 5 deletions storage/2023-11-03/file/shares/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ type DeleteResponse struct {
HttpResponse *http.Response
}

type DeleteSnapshotsType string

const (
DeleteSnapshotsInclude DeleteSnapshotsType = "include"
DeleteSnapshotsIncludeLeased DeleteSnapshotsType = "leased"
)

type DeleteInput struct {
DeleteSnapshots bool
DeleteSnapshotsType DeleteSnapshotsType
}

// Delete deletes the specified Storage Share from within a Storage Account
Expand All @@ -37,7 +44,7 @@ func (c Client) Delete(ctx context.Context, shareName string, input DeleteInput)
},
HttpMethod: http.MethodDelete,
OptionsObject: DeleteOptions{
deleteSnapshots: input.DeleteSnapshots,
deleteSnapshotsType: input.DeleteSnapshotsType,
},
Path: fmt.Sprintf("/%s", shareName),
}
Expand All @@ -61,13 +68,13 @@ func (c Client) Delete(ctx context.Context, shareName string, input DeleteInput)
}

type DeleteOptions struct {
deleteSnapshots bool
deleteSnapshotsType DeleteSnapshotsType
}

func (d DeleteOptions) ToHeaders() *client.Headers {
headers := &client.Headers{}
if d.deleteSnapshots {
headers.Append("x-ms-delete-snapshots", "include")
if d.deleteSnapshotsType != "" {
headers.Append("x-ms-delete-snapshots", string(d.deleteSnapshotsType))
}
return headers
}
Expand Down
6 changes: 3 additions & 3 deletions storage/2023-11-03/file/shares/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestSharesLifecycle(t *testing.T) {
t.Fatalf("Expected 2 identifiers but got %d", len(acls.SignedIdentifiers))
}

_, err = sharesClient.Delete(ctx, shareName, DeleteInput{DeleteSnapshots: false})
_, err = sharesClient.Delete(ctx, shareName, DeleteInput{})
if err != nil {
t.Fatalf("Error deleting Share: %s", err)
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func TestSharesLifecycleLargeQuota(t *testing.T) {
t.Fatalf("Expected 2 identifiers but got %d", len(acls.SignedIdentifiers))
}

_, err = sharesClient.Delete(ctx, shareName, DeleteInput{DeleteSnapshots: false})
_, err = sharesClient.Delete(ctx, shareName, DeleteInput{})
if err != nil {
t.Fatalf("Error deleting Share: %s", err)
}
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestSharesLifecycleNFSProtocol(t *testing.T) {
t.Fatalf(`Expected enabled protocol to be "NFS" but got: %q`, share.EnabledProtocol)
}

_, err = sharesClient.Delete(ctx, shareName, DeleteInput{DeleteSnapshots: false})
_, err = sharesClient.Delete(ctx, shareName, DeleteInput{})
if err != nil {
t.Fatalf("Error deleting Share: %s", err)
}
Expand Down
Loading