Skip to content

Commit da21654

Browse files
committed
Adding GetSystemInformation and verify system health calls to the sdk.
1 parent bd1a7d3 commit da21654

File tree

10 files changed

+353
-32
lines changed

10 files changed

+353
-32
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ NotificationResponse getTapeFailureNotification(GetTapeFailureNotificationReques
296296

297297
DeleteNotificationResponse deleteTapeFailureNotification(DeleteTapeFailureNotificationRequest request)
298298
throws IOException, SignatureException;
299+
300+
GetSystemHealthResponse getSystemHealth(GetSystemHealthRequest request)
301+
throws IOException, SignatureException;
302+
303+
GetSystemInformationResponse getSystemInformation(GetSystemInformationRequest request)
304+
throws IOException, SignatureException;
305+
306+
299307
/**
300308
* Creates a new Ds3Client instance for the system pointed to by Node.
301309
*/

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ public DeleteNotificationResponse deleteTapeFailureNotification(DeleteTapeFailur
245245
return new DeleteNotificationResponse(this.netClient.getResponse(request));
246246
}
247247

248+
@Override
249+
public GetSystemHealthResponse getSystemHealth(final GetSystemHealthRequest request) throws IOException, SignatureException {
250+
return new GetSystemHealthResponse(this.netClient.getResponse(request));
251+
}
252+
253+
@Override
254+
public GetSystemInformationResponse getSystemInformation(final GetSystemInformationRequest request) throws IOException, SignatureException {
255+
return new GetSystemInformationResponse(this.netClient.getResponse(request));
256+
}
257+
248258
@Override
249259
public Ds3Client newForNode(final Node node) {
250260
final ConnectionDetails newConnectionDetails = ConnectionDetailsImpl.newForNode(node, this.getConnectionDetails());
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.HttpVerb;
19+
20+
public class GetSystemHealthRequest extends AbstractRequest {
21+
@Override
22+
public String getPath() {
23+
return "/_rest_/system_health";
24+
}
25+
26+
@Override
27+
public HttpVerb getVerb() {
28+
return HttpVerb.GET;
29+
}
30+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.models.SystemHealth;
19+
import com.spectralogic.ds3client.networking.WebResponse;
20+
import com.spectralogic.ds3client.serializer.XmlOutput;
21+
22+
import java.io.IOException;
23+
import java.io.InputStream;
24+
25+
public class GetSystemHealthResponse extends AbstractResponse {
26+
27+
private SystemHealth systemHealth;
28+
29+
public GetSystemHealthResponse(final WebResponse response) throws IOException {
30+
super(response);
31+
}
32+
33+
@Override
34+
protected void processResponse() throws IOException {
35+
try (final WebResponse response = getResponse()) {
36+
this.checkStatusCode(200);
37+
try (final InputStream inputStream = response.getResponseStream()) {
38+
this.systemHealth = XmlOutput.fromXml(inputStream, SystemHealth.class);
39+
}
40+
}
41+
}
42+
43+
public SystemHealth getSystemHealth() {
44+
return this.systemHealth;
45+
}
46+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.HttpVerb;
19+
20+
public class GetSystemInformationRequest extends AbstractRequest {
21+
@Override
22+
public String getPath() {
23+
return "/_rest_/system_information";
24+
}
25+
26+
@Override
27+
public HttpVerb getVerb() {
28+
return HttpVerb.GET;
29+
}
30+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.models.SystemInformation;
19+
import com.spectralogic.ds3client.networking.WebResponse;
20+
import com.spectralogic.ds3client.serializer.XmlOutput;
21+
22+
import java.io.IOException;
23+
import java.io.InputStream;
24+
25+
public class GetSystemInformationResponse extends AbstractResponse {
26+
27+
private SystemInformation systemInformation;
28+
29+
public GetSystemInformationResponse(final WebResponse response) throws IOException {
30+
super(response);
31+
}
32+
33+
@Override
34+
protected void processResponse() throws IOException {
35+
try (final WebResponse response = getResponse()) {
36+
this.checkStatusCode(200);
37+
try (final InputStream inputStream = response.getResponseStream()) {
38+
this.systemInformation = XmlOutput.fromXml(inputStream, SystemInformation.class);
39+
}
40+
}
41+
}
42+
43+
public SystemInformation getSystemInformation() {
44+
return this.systemInformation;
45+
}
46+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
16+
package com.spectralogic.ds3client.models;
17+
18+
import com.fasterxml.jackson.annotation.JsonProperty;
19+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
20+
21+
@JacksonXmlRootElement(namespace = "Data")
22+
public class SystemHealth {
23+
@JsonProperty("MsRequiredToVerifyDataPlannerHealth")
24+
private long timeToVerifyHealth;
25+
26+
public long getTimeToVerifyHealth() {
27+
return timeToVerifyHealth;
28+
}
29+
30+
public void setTimeToVerifyHealth(long timeToVerifyHealth) {
31+
this.timeToVerifyHealth = timeToVerifyHealth;
32+
}
33+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
16+
package com.spectralogic.ds3client.models;
17+
18+
import com.fasterxml.jackson.annotation.JsonProperty;
19+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
20+
21+
@JacksonXmlRootElement(namespace = "Data")
22+
public class SystemInformation {
23+
@JsonProperty("ApiVersion")
24+
private String apiVersion;
25+
@JsonProperty("BuildInformation")
26+
private BuildInformation buildInformation;
27+
@JsonProperty("SerialNumber")
28+
private String serialNumber;
29+
30+
public String getApiVersion() {
31+
return apiVersion;
32+
}
33+
34+
public void setApiVersion(String apiVersion) {
35+
this.apiVersion = apiVersion;
36+
}
37+
38+
public BuildInformation getBuildInformation() {
39+
return buildInformation;
40+
}
41+
42+
public void setBuildInformation(BuildInformation buildInformation) {
43+
this.buildInformation = buildInformation;
44+
}
45+
46+
public String getSerialNumber() {
47+
return serialNumber;
48+
}
49+
50+
public void setSerialNumber(String serialNumber) {
51+
this.serialNumber = serialNumber;
52+
}
53+
54+
public static class BuildInformation {
55+
@JsonProperty("Branch")
56+
private String branch;
57+
@JsonProperty("Revision")
58+
private String revision;
59+
@JsonProperty("Version")
60+
private String version;
61+
62+
public String getBranch() {
63+
return branch;
64+
}
65+
66+
public void setBranch(String branch) {
67+
this.branch = branch;
68+
}
69+
70+
public String getRevision() {
71+
return revision;
72+
}
73+
74+
public void setRevision(String revision) {
75+
this.revision = revision;
76+
}
77+
78+
public String getVersion() {
79+
return version;
80+
}
81+
82+
public void setVersion(String version) {
83+
this.version = version;
84+
}
85+
}
86+
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/serializer/XmlOutput.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.spectralogic.ds3client.models.bulk.Ds3ObjectList;
2626

2727
import java.io.IOException;
28+
import java.io.InputStream;
2829

2930
public class XmlOutput {
3031
private static final JacksonXmlModule module;
@@ -68,4 +69,8 @@ public static String toXml(final Ds3ObjectList objects, final BulkCommand comman
6869
public static<T> T fromXml(final String xmlString, final Class<T> type) throws IOException {
6970
return mapper.readValue(xmlString, type);
7071
}
72+
73+
public static<T> T fromXml(final InputStream stream, final Class<T> type) throws IOException {
74+
return mapper.readValue(stream, type);
75+
}
7176
}

0 commit comments

Comments
 (0)