Skip to content

Commit 9acaf69

Browse files
committed
Added DeleteTapeParition API command and unit test.
1 parent d5b58e8 commit 9acaf69

File tree

5 files changed

+107
-19
lines changed

5 files changed

+107
-19
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ CancelJobResponse cancelJob(CancelJobRequest request)
228228
ModifyJobResponse modifyJob(ModifyJobRequest request)
229229
throws IOException, SignatureException;
230230

231-
DeleteTapeDriveResponse deleteTapeDrive(DeleteTapeDriveRequest request) throws IOException, SignatureException;
231+
DeleteTapeDriveResponse deleteTapeDrive(DeleteTapeDriveRequest request)
232+
throws IOException, SignatureException;
233+
234+
DeleteTapePartitionResponse deleteTapePartition(DeleteTapePartitionRequest request)
235+
throws IOException, SignatureException;
232236

233237
NotificationResponse createObjectCachedNotification(CreateObjectCachedNotificationRequest request)
234238
throws IOException, SignatureException;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ public DeleteTapeDriveResponse deleteTapeDrive(final DeleteTapeDriveRequest requ
135135
return new DeleteTapeDriveResponse(this.netClient.getResponse(request));
136136
}
137137

138+
@Override
139+
public DeleteTapePartitionResponse deleteTapePartition(final DeleteTapePartitionRequest request) throws IOException, SignatureException {
140+
return new DeleteTapePartitionResponse(this.netClient.getResponse(request));
141+
}
142+
138143
@Override
139144
public NotificationResponse createObjectCachedNotification(final CreateObjectCachedNotificationRequest request) throws IOException, SignatureException {
140145
return new NotificationResponse(this.netClient.getResponse(request));
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
package com.spectralogic.ds3client.commands;
16+
17+
import com.spectralogic.ds3client.HttpVerb;
18+
19+
public class DeleteTapePartitionRequest extends AbstractRequest {
20+
21+
private final String id;
22+
23+
public DeleteTapePartitionRequest(final String id) {
24+
this.id = id;
25+
}
26+
27+
@Override
28+
public String getPath() {
29+
return "/_rest_/tape_partition/" + this.id;
30+
}
31+
32+
@Override
33+
public HttpVerb getVerb() {
34+
return HttpVerb.DELETE;
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
package com.spectralogic.ds3client.commands;
16+
17+
import com.spectralogic.ds3client.networking.WebResponse;
18+
19+
import java.io.IOException;
20+
21+
public class DeleteTapePartitionResponse extends AbstractResponse {
22+
public DeleteTapePartitionResponse(final WebResponse response) throws IOException {
23+
super(response);
24+
}
25+
26+
@Override
27+
protected void processResponse() throws IOException {
28+
try {
29+
this.checkStatusCode(204);
30+
} finally {
31+
this.getResponse().close();
32+
}
33+
}
34+
}

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

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,28 +126,28 @@ public void getBucket() throws IOException, SignatureException {
126126
assertThat(contentsList, is(notNullValue()));
127127
assertThat(contentsList.size(), is(3));
128128
this.assertContentsEquals(
129-
contentsList.get(0),
130-
"user/hduser/gutenberg/20417.txt.utf-8",
131-
"2014-01-03T13:26:47.000Z",
132-
"8B19F3F41868106382A677C3435BDCE5",
133-
674570,
134-
"STANDARD"
129+
contentsList.get(0),
130+
"user/hduser/gutenberg/20417.txt.utf-8",
131+
"2014-01-03T13:26:47.000Z",
132+
"8B19F3F41868106382A677C3435BDCE5",
133+
674570,
134+
"STANDARD"
135135
);
136136
this.assertContentsEquals(
137-
contentsList.get(1),
138-
"user/hduser/gutenberg/5000.txt.utf-8",
139-
"2014-01-03T13:26:47.000Z",
140-
"9DE344878423E44B129730CE22B4B137",
141-
1423803,
142-
"STANDARD"
137+
contentsList.get(1),
138+
"user/hduser/gutenberg/5000.txt.utf-8",
139+
"2014-01-03T13:26:47.000Z",
140+
"9DE344878423E44B129730CE22B4B137",
141+
1423803,
142+
"STANDARD"
143143
);
144144
this.assertContentsEquals(
145-
contentsList.get(2),
146-
"user/hduser/gutenberg/4300.txt.utf-8",
147-
"2014-01-03T13:26:47.000Z",
148-
"33EE4519EA7DDAB27CA4E2742326D70B",
149-
1573150,
150-
"DEEP"
145+
contentsList.get(2),
146+
"user/hduser/gutenberg/4300.txt.utf-8",
147+
"2014-01-03T13:26:47.000Z",
148+
"33EE4519EA7DDAB27CA4E2742326D70B",
149+
1573150,
150+
"DEEP"
151151
);
152152
}
153153

@@ -655,6 +655,15 @@ public void deleteTapeDrive() throws IOException, SignatureException {
655655
assertThat(response, notNullValue());
656656
}
657657

658+
@Test
659+
public void deleteTapePartition() throws IOException, SignatureException {
660+
final DeleteTapePartitionResponse response = MockNetwork
661+
.expecting(HttpVerb.DELETE, "/_rest_/tape_partition/30a8dbf8-12e1-49dd-bede-0b4a7e1dd773", null, null)
662+
.returning(204, "")
663+
.asClient()
664+
.deleteTapePartition(new DeleteTapePartitionRequest("30a8dbf8-12e1-49dd-bede-0b4a7e1dd773"));
665+
assertThat(response, notNullValue());
666+
}
658667
@Test
659668
public void newForNode() {
660669
final Ds3Client client = Ds3ClientBuilder.create("endpoint", new Credentials("access", "key")).build();

0 commit comments

Comments
 (0)