ehdou | b5066cd | 2016-11-10 22:15:42 +0200 | [diff] [blame] | 1 | package securityservices |
| 2 | |
jrperritt | 98d0162 | 2017-01-12 14:24:42 -0600 | [diff] [blame] | 3 | import ( |
| 4 | "encoding/json" |
| 5 | "time" |
| 6 | |
| 7 | "github.com/gophercloud/gophercloud" |
| 8 | ) |
ehdou | b5066cd | 2016-11-10 22:15:42 +0200 | [diff] [blame] | 9 | |
| 10 | // SecurityService contains all the information associated with an OpenStack |
| 11 | // SecurityService. |
| 12 | type SecurityService struct { |
| 13 | // The security service ID |
| 14 | ID string `json:"id"` |
| 15 | // The UUID of the project where the security service was created |
| 16 | ProjectID string `json:"project_id"` |
| 17 | // The security service domain |
| 18 | Domain string `json:"domain"` |
| 19 | // The security service status |
| 20 | Status string `json:"status"` |
| 21 | // The security service type. A valid value is ldap, kerberos, or active_directory |
| 22 | Type string `json:"type"` |
| 23 | // The security service name |
| 24 | Name string `json:"name"` |
| 25 | // The security service description |
| 26 | Description string `json:"description"` |
| 27 | // The DNS IP address that is used inside the tenant network |
| 28 | DNSIP string `json:"dns_ip"` |
| 29 | // The security service user or group name that is used by the tenant |
| 30 | User string `json:"user"` |
| 31 | // The user password, if you specify a user |
| 32 | Password string `json:"password"` |
| 33 | // The security service host name or IP address |
| 34 | Server string `json:"server"` |
| 35 | // The date and time stamp when the security service was created |
jrperritt | 98d0162 | 2017-01-12 14:24:42 -0600 | [diff] [blame] | 36 | CreatedAt time.Time `json:"-"` |
ehdou | b5066cd | 2016-11-10 22:15:42 +0200 | [diff] [blame] | 37 | // The date and time stamp when the security service was updated |
jrperritt | 98d0162 | 2017-01-12 14:24:42 -0600 | [diff] [blame] | 38 | UpdatedAt time.Time `json:"-"` |
| 39 | } |
| 40 | |
| 41 | func (r *SecurityService) UnmarshalJSON(b []byte) error { |
| 42 | type tmp SecurityService |
| 43 | var s struct { |
| 44 | tmp |
| 45 | CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"` |
| 46 | UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"` |
| 47 | } |
| 48 | err := json.Unmarshal(b, &s) |
| 49 | if err != nil { |
| 50 | return err |
| 51 | } |
| 52 | *r = SecurityService(s.tmp) |
| 53 | |
| 54 | r.CreatedAt = time.Time(s.CreatedAt) |
| 55 | r.UpdatedAt = time.Time(s.UpdatedAt) |
| 56 | |
| 57 | return nil |
ehdou | b5066cd | 2016-11-10 22:15:42 +0200 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | type commonResult struct { |
| 61 | gophercloud.Result |
| 62 | } |
| 63 | |
| 64 | // Extract will get the SecurityService object out of the commonResult object. |
| 65 | func (r commonResult) Extract() (*SecurityService, error) { |
| 66 | var s struct { |
| 67 | SecurityService *SecurityService `json:"security_service"` |
| 68 | } |
| 69 | err := r.ExtractInto(&s) |
| 70 | return s.SecurityService, err |
| 71 | } |
| 72 | |
| 73 | // CreateResult contains the response body and error from a Create request. |
| 74 | type CreateResult struct { |
| 75 | commonResult |
| 76 | } |
ehdou | 894b50d | 2017-01-07 00:38:03 +0200 | [diff] [blame] | 77 | |
| 78 | // DeleteResult contains the response body and error from a Delete request. |
| 79 | type DeleteResult struct { |
| 80 | gophercloud.ErrResult |
| 81 | } |