Skip to content

Commit e827963

Browse files
committed
Merge pull request #97 from rpmoore/deleteTape
Adding Delete tape API Call
2 parents 70dcba8 + d0e85ee commit e827963

File tree

5 files changed

+71
-1
lines changed

5 files changed

+71
-1
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ DeleteTapePartitionResponse deleteTapePartition(DeleteTapePartitionRequest reque
280280
GetTapesResponse getTapes(GetTapesRequest request)
281281
throws IOException, SignatureException;
282282

283+
DeleteTapeResponse deleteTape(DeleteTapeRequest request)
284+
throws IOException, SignatureException;
285+
283286
/**
284287
* Returns the information for a single tape.
285288
* @throws IOException

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ public GetTapesResponse getTapes(final GetTapesRequest request) throws IOExcepti
160160
return new GetTapesResponse(this.netClient.getResponse(request));
161161
}
162162

163+
@Override
164+
public DeleteTapeResponse deleteTape(final DeleteTapeRequest request) throws IOException, SignatureException {
165+
return new DeleteTapeResponse(this.netClient.getResponse(request));
166+
}
167+
163168
@Override
164169
public GetTapeResponse getTape(final GetTapeRequest request) throws IOException, SignatureException {
165170
return new GetTapeResponse(this.netClient.getResponse(request));
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.spectralogic.ds3client.commands;
2+
3+
import com.spectralogic.ds3client.HttpVerb;
4+
5+
import java.util.UUID;
6+
7+
public class DeleteTapeRequest extends AbstractRequest {
8+
9+
private final UUID id;
10+
11+
public DeleteTapeRequest(final UUID id) {
12+
this.id = id;
13+
}
14+
15+
@Override
16+
public String getPath() {
17+
return "/_rest_/tape/" + id.toString();
18+
}
19+
20+
@Override
21+
public HttpVerb getVerb() {
22+
return HttpVerb.DELETE;
23+
}
24+
25+
public UUID getId() {
26+
return id;
27+
}
28+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.spectralogic.ds3client.commands;
2+
3+
import com.spectralogic.ds3client.networking.WebResponse;
4+
5+
import java.io.IOException;
6+
7+
public class DeleteTapeResponse extends AbstractResponse {
8+
public DeleteTapeResponse(final WebResponse response) throws IOException {
9+
super(response);
10+
}
11+
12+
@Override
13+
protected void processResponse() throws IOException {
14+
try {
15+
checkStatusCode(204);
16+
} finally {
17+
getResponse().close();
18+
}
19+
}
20+
}

ds3-sdk/src/test/java/com/spectralogic/ds3client/Ds3Client_Test.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public void deleteFolder() throws IOException, SignatureException {
235235
.expecting(HttpVerb.DELETE, "/_rest_/folder/folderName", queryParams, null)
236236
.returning(204, "")
237237
.asClient()
238-
.deleteFolder(new DeleteFolderRequest("bucketName","folderName"));
238+
.deleteFolder(new DeleteFolderRequest("bucketName", "folderName"));
239239
}
240240

241241
@Test
@@ -891,6 +891,20 @@ public void getTapes() throws IOException, SignatureException {
891891
assertThat(tapes.get(0).getId(), is(notNullValue()));
892892
}
893893

894+
@Test
895+
public void deleteTape() throws IOException, SignatureException {
896+
897+
final UUID id = UUID.randomUUID();
898+
899+
final DeleteTapeResponse response = MockNetwork
900+
.expecting(HttpVerb.DELETE, "/_rest_/tape/" + id.toString(), null, null)
901+
.returning(204, "")
902+
.asClient()
903+
.deleteTape(new DeleteTapeRequest(id));
904+
905+
assertThat(response, is(notNullValue()));
906+
}
907+
894908
@Test
895909
public void getTape() throws IOException, SignatureException {
896910
final String responsePayload = "<Data><AssignedToBucket>false</AssignedToBucket><AvailableRawCapacity>2408082046976</AvailableRawCapacity><BarCode>101000L6</BarCode><BucketId/><DescriptionForIdentification/><EjectDate/><EjectLabel/><EjectLocation/><EjectPending/><FullOfData>false</FullOfData><Id>c7c431df-f95d-4533-b350-ffd7a8a5caac</Id><LastAccessed>2015-09-04 06:53:08.236</LastAccessed><LastCheckpoint>eb77ea67-3c83-47ec-8714-cd46a97dc392:2</LastCheckpoint><LastModified>2015-08-21 16:14:30.714</LastModified><LastVerified/><PartitionId>4f8a5cbb-9837-41d9-afd1-cebed41f18f7</PartitionId><PreviousState/><SerialNumber>HP-W130501213</SerialNumber><State>NORMAL</State><TotalRawCapacity>2408088338432</TotalRawCapacity><Type>LTO6</Type><WriteProtected>false</WriteProtected></Data>";

0 commit comments

Comments
 (0)