From cb38f09f46f57e4a242083cca2995831f67e01b5 Mon Sep 17 00:00:00 2001 From: Rachel Tucker Date: Fri, 9 Mar 2018 11:54:21 -0700 Subject: [PATCH] Adding undelete object command --- contract/5_0_x_contract.xml | 32 +++++++ .../com/spectralogic/ds3client/Ds3Client.java | 7 ++ .../spectralogic/ds3client/Ds3ClientImpl.java | 4 + ...UndeleteObjectSpectraS3ResponseParser.java | 49 +++++++++++ .../UndeleteObjectSpectraS3Request.java | 86 +++++++++++++++++++ .../UndeleteObjectSpectraS3Response.java | 36 ++++++++ 6 files changed, 214 insertions(+) create mode 100644 ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/parsers/UndeleteObjectSpectraS3ResponseParser.java create mode 100644 ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/UndeleteObjectSpectraS3Request.java create mode 100644 ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/UndeleteObjectSpectraS3Response.java diff --git a/contract/5_0_x_contract.xml b/contract/5_0_x_contract.xml index 995e50815..2eead26af 100644 --- a/contract/5_0_x_contract.xml +++ b/contract/5_0_x_contract.xml @@ -4602,6 +4602,32 @@ 1.BDA9A7110ADB2C122D0CA705B6B1D6FA + + + + + + + + + + + + + 200 + + + + + + 404 + + + + + + 1.94C075BD3FE76604F8ED084C9B9E4AE5 + @@ -5442,6 +5468,12 @@ + + 400 + + + + 1.2861D535C9E907B2316C6DD326F9C9DB diff --git a/ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java b/ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java index 67a96a7ac..3aeefa580 100644 --- a/ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java +++ b/ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java @@ -1379,6 +1379,13 @@ GetPhysicalPlacementForObjectsSpectraS3Response getPhysicalPlacementForObjectsSp GetPhysicalPlacementForObjectsWithFullDetailsSpectraS3Response getPhysicalPlacementForObjectsWithFullDetailsSpectraS3(final GetPhysicalPlacementForObjectsWithFullDetailsSpectraS3Request request) throws IOException; + @ResponsePayloadModel("S3Object") + @Action("BULK_MODIFY") + @Resource("OBJECT") + + UndeleteObjectSpectraS3Response undeleteObjectSpectraS3(final UndeleteObjectSpectraS3Request request) + throws IOException; + @ResponsePayloadModel("PhysicalPlacement") @Action("SHOW") @Resource("BUCKET") diff --git a/ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java b/ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java index 425e4e8d0..e8b752e61 100644 --- a/ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java +++ b/ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java @@ -858,6 +858,10 @@ public GetPhysicalPlacementForObjectsWithFullDetailsSpectraS3Response getPhysica return new GetPhysicalPlacementForObjectsWithFullDetailsSpectraS3ResponseParser().response(this.netClient.getResponse(request)); } @Override + public UndeleteObjectSpectraS3Response undeleteObjectSpectraS3(final UndeleteObjectSpectraS3Request request) throws IOException { + return new UndeleteObjectSpectraS3ResponseParser().response(this.netClient.getResponse(request)); + } + @Override public VerifyPhysicalPlacementForObjectsSpectraS3Response verifyPhysicalPlacementForObjectsSpectraS3(final VerifyPhysicalPlacementForObjectsSpectraS3Request request) throws IOException { return new VerifyPhysicalPlacementForObjectsSpectraS3ResponseParser().response(this.netClient.getResponse(request)); } diff --git a/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/parsers/UndeleteObjectSpectraS3ResponseParser.java b/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/parsers/UndeleteObjectSpectraS3ResponseParser.java new file mode 100644 index 000000000..709f25eb7 --- /dev/null +++ b/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/parsers/UndeleteObjectSpectraS3ResponseParser.java @@ -0,0 +1,49 @@ +/* + * ****************************************************************************** + * Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use + * this file except in compliance with the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * **************************************************************************** + */ + +// This code is auto-generated, do not modify +package com.spectralogic.ds3client.commands.parsers; + +import com.spectralogic.ds3client.commands.parsers.interfaces.AbstractResponseParser; +import com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils; +import com.spectralogic.ds3client.commands.spectrads3.UndeleteObjectSpectraS3Response; +import com.spectralogic.ds3client.models.S3Object; +import com.spectralogic.ds3client.networking.WebResponse; +import com.spectralogic.ds3client.serializer.XmlOutput; +import java.io.IOException; +import java.io.InputStream; + +public class UndeleteObjectSpectraS3ResponseParser extends AbstractResponseParser { + private final int[] expectedStatusCodes = new int[]{200}; + + @Override + public UndeleteObjectSpectraS3Response parseXmlResponse(final WebResponse response) throws IOException { + final int statusCode = response.getStatusCode(); + if (ResponseParserUtils.validateStatusCode(statusCode, expectedStatusCodes)) { + switch (statusCode) { + case 200: + try (final InputStream inputStream = response.getResponseStream()) { + final S3Object result = XmlOutput.fromXml(inputStream, S3Object.class); + return new UndeleteObjectSpectraS3Response(result, this.getChecksum(), this.getChecksumType()); + } + + default: + assert false: "validateStatusCode should have made it impossible to reach this line"; + } + } + + throw ResponseParserUtils.createFailedRequest(response, expectedStatusCodes); + } +} \ No newline at end of file diff --git a/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/UndeleteObjectSpectraS3Request.java b/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/UndeleteObjectSpectraS3Request.java new file mode 100644 index 000000000..353eea17f --- /dev/null +++ b/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/UndeleteObjectSpectraS3Request.java @@ -0,0 +1,86 @@ +/* + * ****************************************************************************** + * Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use + * this file except in compliance with the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * **************************************************************************** + */ + +// This code is auto-generated, do not modify +package com.spectralogic.ds3client.commands.spectrads3; + +import com.spectralogic.ds3client.networking.HttpVerb; +import com.spectralogic.ds3client.commands.interfaces.AbstractRequest; +import com.google.common.net.UrlEscapers; +import java.util.UUID; + +public class UndeleteObjectSpectraS3Request extends AbstractRequest { + + // Variables + + private final String bucketId; + + private final String name; + + private String versionId; + + // Constructor + + + public UndeleteObjectSpectraS3Request(final String bucketId, final String name) { + this.bucketId = bucketId; + this.name = name; + + this.updateQueryParam("bucket_id", bucketId); + + this.updateQueryParam("name", name); + + } + + public UndeleteObjectSpectraS3Request withVersionId(final UUID versionId) { + this.versionId = versionId.toString(); + this.updateQueryParam("version_id", versionId); + return this; + } + + + public UndeleteObjectSpectraS3Request withVersionId(final String versionId) { + this.versionId = versionId; + this.updateQueryParam("version_id", versionId); + return this; + } + + + + @Override + public HttpVerb getVerb() { + return HttpVerb.PUT; + } + + @Override + public String getPath() { + return "/_rest_/object"; + } + + public String getBucketId() { + return this.bucketId; + } + + + public String getName() { + return this.name; + } + + + public String getVersionId() { + return this.versionId; + } + +} \ No newline at end of file diff --git a/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/UndeleteObjectSpectraS3Response.java b/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/UndeleteObjectSpectraS3Response.java new file mode 100644 index 000000000..a271af52f --- /dev/null +++ b/ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/UndeleteObjectSpectraS3Response.java @@ -0,0 +1,36 @@ +/* + * ****************************************************************************** + * Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use + * this file except in compliance with the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * **************************************************************************** + */ + +// This code is auto-generated, do not modify +package com.spectralogic.ds3client.commands.spectrads3; + +import com.spectralogic.ds3client.models.S3Object; +import com.spectralogic.ds3client.models.ChecksumType; +import com.spectralogic.ds3client.commands.interfaces.AbstractResponse; + +public class UndeleteObjectSpectraS3Response extends AbstractResponse { + + private final S3Object s3ObjectResult; + + public UndeleteObjectSpectraS3Response(final S3Object s3ObjectResult, final String checksum, final ChecksumType.Type checksumType) { + super(checksum, checksumType); + this.s3ObjectResult = s3ObjectResult; + } + + public S3Object getS3ObjectResult() { + return this.s3ObjectResult; + } + +} \ No newline at end of file