-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1226 from jyothisaroja/cached_images
Implement listCachedImages() for Glance V2 Images
- Loading branch information
Showing
4 changed files
with
150 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
41 changes: 41 additions & 0 deletions
41
core/src/main/java/org/openstack4j/model/image/v2/CachedImage.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.openstack4j.model.image.v2; | ||
|
||
import org.openstack4j.model.ModelEntity; | ||
import java.util.Date; | ||
|
||
/** | ||
* @author zdagjyo on 13/11/2018. | ||
* @see https://docs.openstack.org/developer/glance/cache.html | ||
*/ | ||
public interface CachedImage extends ModelEntity { | ||
|
||
/** | ||
* | ||
* @return the image id of the cached image | ||
*/ | ||
String getImageId(); | ||
|
||
/** | ||
* | ||
* @return date when this image was last accessed in the cache | ||
*/ | ||
Date getLastAccessed(); | ||
|
||
/** | ||
* | ||
* @return date when the image was last modified in the cache | ||
*/ | ||
Date getLastModified(); | ||
|
||
/** | ||
* | ||
* @return nr of cache hits | ||
*/ | ||
Integer getHits(); | ||
|
||
/** | ||
* | ||
* @return the image size | ||
*/ | ||
Long getSize(); | ||
} |
82 changes: 82 additions & 0 deletions
82
core/src/main/java/org/openstack4j/openstack/image/v2/domain/CachedGlanceImage.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.openstack4j.openstack.image.v2.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.google.common.base.Objects; | ||
import org.openstack4j.model.image.v2.CachedImage; | ||
import org.openstack4j.openstack.common.CustomEpochToDateDeserializer; | ||
import org.openstack4j.openstack.common.ListResult; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
/** | ||
* @author zdagjyo on 13/11/2018. | ||
*/ | ||
public class CachedGlanceImage implements CachedImage { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@JsonProperty("image_id") | ||
private String imageId; | ||
|
||
private Integer hits; | ||
|
||
@JsonProperty("last_accessed") | ||
@JsonDeserialize(using = CustomEpochToDateDeserializer.class) | ||
private Date lastAccessed; | ||
|
||
@JsonDeserialize(using = CustomEpochToDateDeserializer.class) | ||
@JsonProperty("last_modified") | ||
private Date lastModified; | ||
|
||
private Long size; | ||
|
||
@Override | ||
public String getImageId() { | ||
return imageId; | ||
} | ||
|
||
@Override | ||
public Date getLastAccessed() { | ||
return lastAccessed; | ||
} | ||
|
||
@Override | ||
public Date getLastModified() { | ||
return lastModified; | ||
} | ||
|
||
@Override | ||
public Integer getHits() { | ||
return hits; | ||
} | ||
|
||
@Override | ||
public Long getSize() { | ||
return size; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String toString() { | ||
return Objects.toStringHelper(this).omitNullValues() | ||
.add("id", imageId).add("size", size).add("hits", hits).add("lastAccessed", lastAccessed) | ||
.add("lastModified", lastModified).addValue("\n") | ||
.toString(); | ||
} | ||
|
||
public static class CachedImages extends ListResult<CachedGlanceImage> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
@JsonProperty("cached_images") | ||
private List<CachedGlanceImage> cachedImages; | ||
|
||
@Override | ||
protected List<CachedGlanceImage> value() { | ||
return cachedImages; | ||
} | ||
} | ||
} |
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