change all time fields to have type time.Time (#190)
* add Volume.Unmarshal
* add volumetenants.VolumeExt.Unmarshal
* create servers.Server time.Time fields
* json.Unmarshal can correctly handle time.RFC3339 (Server time fields)
* add v3 Token UnmarshalJSON method
* check for empty string when unmarshaling time
* add Member UnmarshalJSON
* v3 tokens.Token ExtractInto
* v3 trust.Trust UnmarshalJSON
* time.Time fields swift response objects
* time.Time fields for orchestration response objects
* time.Time fields for shared file systems response objects
* if we don't use pointers for the custom time fields, we don't need to check if they're nil
* style guide fixes: 'r' for receiver, 's' for struct
* remove unnecessary pointers from UnmarshalJSON methods
diff --git a/openstack/sharedfilesystems/v2/securityservices/results.go b/openstack/sharedfilesystems/v2/securityservices/results.go
index 746b2b3..6874208 100644
--- a/openstack/sharedfilesystems/v2/securityservices/results.go
+++ b/openstack/sharedfilesystems/v2/securityservices/results.go
@@ -1,6 +1,11 @@
package securityservices
-import "github.com/gophercloud/gophercloud"
+import (
+ "encoding/json"
+ "time"
+
+ "github.com/gophercloud/gophercloud"
+)
// SecurityService contains all the information associated with an OpenStack
// SecurityService.
@@ -28,9 +33,28 @@
// The security service host name or IP address
Server string `json:"server"`
// The date and time stamp when the security service was created
- CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"`
+ CreatedAt time.Time `json:"-"`
// The date and time stamp when the security service was updated
- UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"`
+ UpdatedAt time.Time `json:"-"`
+}
+
+func (r *SecurityService) UnmarshalJSON(b []byte) error {
+ type tmp SecurityService
+ var s struct {
+ tmp
+ CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"`
+ UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"`
+ }
+ err := json.Unmarshal(b, &s)
+ if err != nil {
+ return err
+ }
+ *r = SecurityService(s.tmp)
+
+ r.CreatedAt = time.Time(s.CreatedAt)
+ r.UpdatedAt = time.Time(s.UpdatedAt)
+
+ return nil
}
type commonResult struct {