From 3b61d6de3152725439c4fe4db482556ca5d6563f Mon Sep 17 00:00:00 2001 From: Glenn Lewis Date: Fri, 26 Sep 2014 12:34:15 -0700 Subject: [PATCH 1/2] Add new fields: StorageClass, TimeDeleted, and Updated. --- storage/object.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/storage/object.go b/storage/object.go index 9e858db30e76..18da9e28bb72 100644 --- a/storage/object.go +++ b/storage/object.go @@ -16,6 +16,7 @@ package storage import ( "io" + "time" raw "code.google.com/p/google-api-go-client/storage/v1" ) @@ -100,7 +101,17 @@ type Object struct { // Read-only. MetaGeneration int64 `json:"metageneration,omitempty"` - // TODO(jbd): Add timeDelete and updated. + // StorageClass: Storage class of the object. + StorageClass string `json:"storageClass,omitempty"` + + // TimeDeleted: The deletion time of the object. + // This will be non-zero if and only if this version of the object has been deleted. + TimeDeleted time.Time `json:"timeDeleted,omitempty"` + + // Updated: The creation or modification time of the object. + // For buckets with versioning enabled, changing an object's + // metadata does not change this property. + Updated time.Time `json:"updated,omitempty"` } func (o *Object) toRawObject() *raw.Object { @@ -121,6 +132,16 @@ func (o *Object) toRawObject() *raw.Object { } } +// convertTime converts a time in RFC3339 format to time.Time. +// If any error occurs in parsing, the zero-value time.Time is silently returned. +func convertTime(t string) time.Time { + var r time.Time + if t != "" { + r, _ = time.Parse(time.RFC3339, t) + } + return r +} + func newObject(o *raw.Object) *Object { if o == nil { return nil @@ -146,6 +167,9 @@ func newObject(o *raw.Object) *Object { Metadata: o.Metadata, Generation: o.Generation, MetaGeneration: o.Metageneration, + StorageClass: o.StorageClass, + TimeDeleted: convertTime(o.TimeDeleted), + Updated: convertTime(o.Updated), } } From 32b9271fb01110dd55f01d79470f7c52a9c2c4c5 Mon Sep 17 00:00:00 2001 From: Glenn Lewis Date: Fri, 26 Sep 2014 14:42:56 -0700 Subject: [PATCH 2/2] Make descriptions full sentences and change TimeDeleted to Deleted. --- storage/object.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/object.go b/storage/object.go index 18da9e28bb72..36bdd01def1c 100644 --- a/storage/object.go +++ b/storage/object.go @@ -101,14 +101,14 @@ type Object struct { // Read-only. MetaGeneration int64 `json:"metageneration,omitempty"` - // StorageClass: Storage class of the object. + // StorageClass is the storage class of the object. StorageClass string `json:"storageClass,omitempty"` - // TimeDeleted: The deletion time of the object. + // Deleted is the deletion time of the object (or the zero-value time). // This will be non-zero if and only if this version of the object has been deleted. - TimeDeleted time.Time `json:"timeDeleted,omitempty"` + Deleted time.Time `json:"timeDeleted,omitempty"` - // Updated: The creation or modification time of the object. + // Updated is the creation or modification time of the object. // For buckets with versioning enabled, changing an object's // metadata does not change this property. Updated time.Time `json:"updated,omitempty"` @@ -168,7 +168,7 @@ func newObject(o *raw.Object) *Object { Generation: o.Generation, MetaGeneration: o.Metageneration, StorageClass: o.StorageClass, - TimeDeleted: convertTime(o.TimeDeleted), + Deleted: convertTime(o.TimeDeleted), Updated: convertTime(o.Updated), } }