Skip to content

Commit

Permalink
Merge pull request #97 from rpmoore/deleteTape
Browse files Browse the repository at this point in the history
Adding Delete tape API Call
  • Loading branch information
RachelTucker committed Sep 25, 2015
2 parents 70dcba8 + d0e85ee commit e827963
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ DeleteTapePartitionResponse deleteTapePartition(DeleteTapePartitionRequest reque
GetTapesResponse getTapes(GetTapesRequest request)
throws IOException, SignatureException;

DeleteTapeResponse deleteTape(DeleteTapeRequest request)
throws IOException, SignatureException;

/**
* Returns the information for a single tape.
* @throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ public GetTapesResponse getTapes(final GetTapesRequest request) throws IOExcepti
return new GetTapesResponse(this.netClient.getResponse(request));
}

@Override
public DeleteTapeResponse deleteTape(final DeleteTapeRequest request) throws IOException, SignatureException {
return new DeleteTapeResponse(this.netClient.getResponse(request));
}

@Override
public GetTapeResponse getTape(final GetTapeRequest request) throws IOException, SignatureException {
return new GetTapeResponse(this.netClient.getResponse(request));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.spectralogic.ds3client.commands;

import com.spectralogic.ds3client.HttpVerb;

import java.util.UUID;

public class DeleteTapeRequest extends AbstractRequest {

private final UUID id;

public DeleteTapeRequest(final UUID id) {
this.id = id;
}

@Override
public String getPath() {
return "/_rest_/tape/" + id.toString();
}

@Override
public HttpVerb getVerb() {
return HttpVerb.DELETE;
}

public UUID getId() {
return id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.spectralogic.ds3client.commands;

import com.spectralogic.ds3client.networking.WebResponse;

import java.io.IOException;

public class DeleteTapeResponse extends AbstractResponse {
public DeleteTapeResponse(final WebResponse response) throws IOException {
super(response);
}

@Override
protected void processResponse() throws IOException {
try {
checkStatusCode(204);
} finally {
getResponse().close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void deleteFolder() throws IOException, SignatureException {
.expecting(HttpVerb.DELETE, "/_rest_/folder/folderName", queryParams, null)
.returning(204, "")
.asClient()
.deleteFolder(new DeleteFolderRequest("bucketName","folderName"));
.deleteFolder(new DeleteFolderRequest("bucketName", "folderName"));
}

@Test
Expand Down Expand Up @@ -891,6 +891,20 @@ public void getTapes() throws IOException, SignatureException {
assertThat(tapes.get(0).getId(), is(notNullValue()));
}

@Test
public void deleteTape() throws IOException, SignatureException {

final UUID id = UUID.randomUUID();

final DeleteTapeResponse response = MockNetwork
.expecting(HttpVerb.DELETE, "/_rest_/tape/" + id.toString(), null, null)
.returning(204, "")
.asClient()
.deleteTape(new DeleteTapeRequest(id));

assertThat(response, is(notNullValue()));
}

@Test
public void getTape() throws IOException, SignatureException {
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>";
Expand Down

0 comments on commit e827963

Please sign in to comment.