Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
JCLOUDS-457: Added initiateJob
Now the Glacier client supports the initiateJob operation.
- Loading branch information
Showing
10 changed files
with
544 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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. | ||
*/ | ||
package org.jclouds.glacier.binders; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import org.jclouds.glacier.domain.JobRequest; | ||
import org.jclouds.http.HttpRequest; | ||
import org.jclouds.json.Json; | ||
import org.jclouds.rest.Binder; | ||
|
||
import com.google.inject.Inject; | ||
|
||
public class BindJobRequestToJsonPayload implements Binder { | ||
@Inject | ||
private Json json; | ||
|
||
@Override | ||
public <R extends HttpRequest> R bindToRequest(R request, Object input) { | ||
checkArgument(checkNotNull(input, "input") instanceof JobRequest, | ||
"This binder is only valid for JobRequest"); | ||
checkNotNull(request, "request"); | ||
request.setPayload(json.toJson(input)); | ||
return request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,117 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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. | ||
*/ | ||
package org.jclouds.glacier.domain; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import java.beans.ConstructorProperties; | ||
|
||
import org.jclouds.glacier.util.ContentRange; | ||
import org.jclouds.javax.annotation.Nullable; | ||
|
||
import com.google.common.base.Objects; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
public class ArchiveRetrievalJobRequest extends JobRequest { | ||
private static final String TYPE = "archive-retrieval"; | ||
|
||
@SerializedName("ArchiveId") | ||
private final String archiveId; | ||
@SerializedName("Description") | ||
private final String description; | ||
@SerializedName("RetrievalByteRange") | ||
private final ContentRange range; | ||
|
||
private ArchiveRetrievalJobRequest(String archiveId, @Nullable String description, @Nullable ContentRange range) { | ||
super(TYPE); | ||
this.archiveId = checkNotNull(archiveId, "archiveId"); | ||
this.description = description; | ||
this.range = range; | ||
} | ||
|
||
@ConstructorProperties({ "ArchiveId", "Description", "RetrievalByteRange" }) | ||
private ArchiveRetrievalJobRequest(String archiveId, @Nullable String description, @Nullable String range) { | ||
this(archiveId, description, range == null ? null : ContentRange.fromString(range)); | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public ContentRange getRange() { | ||
return range; | ||
} | ||
|
||
public String getArchiveId() { | ||
return archiveId; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(this.archiveId, this.description, this.range); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
ArchiveRetrievalJobRequest other = (ArchiveRetrievalJobRequest) obj; | ||
|
||
return Objects.equal(this.archiveId, other.archiveId) && Objects.equal(this.description, other.description) | ||
&& Objects.equal(this.range, other.range); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "InventoryRetrievalParameters [archiveId=" + archiveId + ", description=" + description + ", range=" | ||
+ range + "]"; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
private String archiveId; | ||
private String description; | ||
private ContentRange range; | ||
|
||
Builder() { | ||
} | ||
|
||
public Builder archiveId(String archiveId) { | ||
this.archiveId = archiveId; | ||
return this; | ||
} | ||
|
||
public Builder description(String description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
public Builder range(ContentRange range) { | ||
this.range = range; | ||
return this; | ||
} | ||
|
||
public ArchiveRetrievalJobRequest build() { | ||
return new ArchiveRetrievalJobRequest(archiveId, description, range); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,133 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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. | ||
*/ | ||
package org.jclouds.glacier.domain; | ||
|
||
import java.beans.ConstructorProperties; | ||
|
||
import org.jclouds.javax.annotation.Nullable; | ||
|
||
import com.google.common.base.Objects; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
public class InventoryRetrievalJobRequest extends JobRequest { | ||
private static final String TYPE = "inventory-retrieval"; | ||
|
||
@SerializedName("Description") | ||
private final String description; | ||
@SerializedName("Format") | ||
private final String format; | ||
@SerializedName("InventoryRetrievalParameters") | ||
private final InventoryRetrievalParameters parameters; | ||
|
||
@ConstructorProperties({ "Description", "Format" }) | ||
private InventoryRetrievalJobRequest(@Nullable String description, @Nullable String format) { | ||
super(TYPE); | ||
this.description = description; | ||
this.format = format; | ||
this.parameters = new InventoryRetrievalParameters(); | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getFormat() { | ||
return format; | ||
} | ||
|
||
public InventoryRetrievalParameters getParameters() { | ||
return this.parameters; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(this.description, this.format, this.parameters); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
InventoryRetrievalJobRequest other = (InventoryRetrievalJobRequest) obj; | ||
|
||
return Objects.equal(this.description, other.description) && Objects.equal(this.format, other.format) | ||
&& Objects.equal(this.parameters, other.parameters); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "InventoryRetrievalJobRequest [description=" + description + ", format=" + format + "," + | ||
"parameters=" + parameters + "]"; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
private String description; | ||
private String format; | ||
private String startDate; | ||
private String endDate; | ||
private Integer limit; | ||
private String marker; | ||
|
||
Builder() { | ||
} | ||
|
||
public Builder description(String description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
public Builder format(String format) { | ||
this.format = format; | ||
return this; | ||
} | ||
|
||
public Builder startDate(String startDate) { | ||
this.startDate = startDate; | ||
return this; | ||
} | ||
|
||
public Builder endDate(String endDate) { | ||
this.endDate = endDate; | ||
return this; | ||
} | ||
|
||
public Builder limit(Integer limit) { | ||
this.limit = limit; | ||
return this; | ||
} | ||
|
||
public Builder marker(String marker) { | ||
this.marker = marker; | ||
return this; | ||
} | ||
|
||
public InventoryRetrievalJobRequest build() { | ||
InventoryRetrievalJobRequest request = new InventoryRetrievalJobRequest(description, format); | ||
request.getParameters().setEndDate(endDate); | ||
request.getParameters().setStartDate(startDate); | ||
request.getParameters().setLimit(limit); | ||
request.getParameters().setMarker(marker); | ||
return request; | ||
} | ||
} | ||
} |
Oops, something went wrong.