|
| 1 | +package request |
| 2 | + |
| 3 | +import ( |
| 4 | + "encoding/json" |
| 5 | + "fmt" |
| 6 | +) |
| 7 | + |
| 8 | +// GetObjectStorageDetailsRequest represents a request for retrieving details about a Object Storage device |
| 9 | +type GetObjectStorageDetailsRequest struct { |
| 10 | + UUID string |
| 11 | +} |
| 12 | + |
| 13 | +// RequestURL implements the Request interface |
| 14 | +func (r *GetObjectStorageDetailsRequest) RequestURL() string { |
| 15 | + return fmt.Sprintf("/object-storage/%s", r.UUID) |
| 16 | +} |
| 17 | + |
| 18 | +// CreateObjectStorageRequest represents a request for creating a new Object Storage device |
| 19 | +type CreateObjectStorageRequest struct { |
| 20 | + Name string `json:"name,omitempty"` |
| 21 | + Description string `json:"description,omitempty"` |
| 22 | + Zone string `json:"zone"` |
| 23 | + AccessKey string `json:"access_key"` |
| 24 | + SecretKey string `json:"secret_key"` |
| 25 | + Size int `json:"size"` |
| 26 | +} |
| 27 | + |
| 28 | +// MarshalJSON is a custom marshaller that deals with |
| 29 | +// deeply embedded values. |
| 30 | +func (r CreateObjectStorageRequest) MarshalJSON() ([]byte, error) { |
| 31 | + type localCreateObjectStorageRequest CreateObjectStorageRequest |
| 32 | + v := struct { |
| 33 | + ObjectStorage localCreateObjectStorageRequest `json:"object_storage"` |
| 34 | + }{} |
| 35 | + v.ObjectStorage = localCreateObjectStorageRequest(r) |
| 36 | + |
| 37 | + return json.Marshal(&v) |
| 38 | +} |
| 39 | + |
| 40 | +// RequestURL implements the Request interface |
| 41 | +func (r *CreateObjectStorageRequest) RequestURL() string { |
| 42 | + return "/object-storage" |
| 43 | +} |
| 44 | + |
| 45 | +// ModifyObjectStorageRequest represents a request to modify a Object Storage |
| 46 | +type ModifyObjectStorageRequest struct { |
| 47 | + UUID string `json:"-"` |
| 48 | + Description string `json:"description,omitempty"` |
| 49 | + AccessKey string `json:"access_key,omitempty"` |
| 50 | + SecretKey string `json:"secret_key,omitempty"` |
| 51 | + Size int `json:"size,omitempty"` |
| 52 | +} |
| 53 | + |
| 54 | +// MarshalJSON is a custom marshaller that deals with |
| 55 | +// deeply embedded values. |
| 56 | +func (r ModifyObjectStorageRequest) MarshalJSON() ([]byte, error) { |
| 57 | + type localModifyObjectStorageRequest ModifyObjectStorageRequest |
| 58 | + v := struct { |
| 59 | + ModifyObjectStorageRequest localModifyObjectStorageRequest `json:"object_storage"` |
| 60 | + }{} |
| 61 | + v.ModifyObjectStorageRequest = localModifyObjectStorageRequest(r) |
| 62 | + |
| 63 | + return json.Marshal(&v) |
| 64 | +} |
| 65 | + |
| 66 | +// RequestURL implements the Request interface |
| 67 | +func (r *ModifyObjectStorageRequest) RequestURL() string { |
| 68 | + return fmt.Sprintf("/object-storage/%s", r.UUID) |
| 69 | +} |
| 70 | + |
| 71 | +// DeleteObjectStorageRequest represents a request to delete a Object Storage |
| 72 | +type DeleteObjectStorageRequest struct { |
| 73 | + UUID string |
| 74 | +} |
| 75 | + |
| 76 | +// RequestURL implements the Request interface |
| 77 | +func (r *DeleteObjectStorageRequest) RequestURL() string { |
| 78 | + return fmt.Sprintf("/object-storage/%s", r.UUID) |
| 79 | +} |
0 commit comments