github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/rts/v1/softwareconfig/results.go (about) 1 package softwareconfig 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 type SoftwareConfig struct { 9 // Specifies the software configuration input. 10 Inputs []map[string]interface{} `json:"inputs"` 11 //Specifies the name of the software configuration. 12 Name string `json:"name"` 13 //Specifies the software configuration output. 14 Outputs []map[string]interface{} `json:"outputs"` 15 //Specifies the time when a configuration is created. 16 CreationTime golangsdk.JSONRFC3339NoZ `json:"creation_time"` 17 //Specifies the name of the software configuration group. 18 Group string `json:"group"` 19 //Specifies the configuration code. 20 Config string `json:"config"` 21 //Specifies configuration options. 22 Options map[string]interface{} `json:"options"` 23 //Specifies the software configuration ID. 24 Id string `json:"id"` 25 } 26 27 // SoftwareConfigPage is the page returned by a pager when traversing over a 28 // collection of Software Configurations. 29 type SoftwareConfigPage struct { 30 pagination.LinkedPageBase 31 } 32 33 // NextPageURL is invoked when a paginated collection of Software Configs has reached 34 // the end of a page and the pager seeks to traverse over a new one. In order 35 // to do this, it needs to construct the next page's URL. 36 func (r SoftwareConfigPage) NextPageURL() (string, error) { 37 var s struct { 38 Links []golangsdk.Link `json:"software_config_links"` 39 } 40 err := r.ExtractInto(&s) 41 if err != nil { 42 return "", err 43 } 44 return golangsdk.ExtractNextURL(s.Links) 45 } 46 47 // IsEmpty checks whether a SoftwareConfigPage struct is empty. 48 func (r SoftwareConfigPage) IsEmpty() (bool, error) { 49 is, err := ExtractSoftwareConfigs(r) 50 return len(is) == 0, err 51 } 52 53 // ExtractSoftwareConfigs accepts a Page struct, specifically a SoftwareConfigPage struct, 54 // and extracts the elements into a slice of Software Configs structs. In other words, 55 // a generic collection is mapped into a relevant slice. 56 func ExtractSoftwareConfigs(r pagination.Page) ([]SoftwareConfig, error) { 57 var s struct { 58 SoftwareConfigs []SoftwareConfig `json:"software_configs"` 59 } 60 err := (r.(SoftwareConfigPage)).ExtractInto(&s) 61 return s.SoftwareConfigs, err 62 } 63 64 type commonResult struct { 65 golangsdk.Result 66 } 67 68 // Extract is a function that accepts a result and extracts a Software configuration. 69 func (r commonResult) Extract() (*SoftwareConfig, error) { 70 var s struct { 71 SoftwareConfig *SoftwareConfig `json:"software_config"` 72 } 73 err := r.ExtractInto(&s) 74 return s.SoftwareConfig, err 75 } 76 77 // CreateResult represents the result of a create operation. Call its Extract 78 // method to interpret it as a Software configuration. 79 type CreateResult struct { 80 commonResult 81 } 82 83 // GetResult represents the result of a get operation. Call its Extract 84 // method to interpret it as a Software configuration. 85 type GetResult struct { 86 commonResult 87 } 88 89 // UpdateResult represents the result of an update operation. Call its Extract 90 // method to interpret it as a Software configuration. 91 type UpdateResult struct { 92 commonResult 93 } 94 95 // DeleteResult represents the result of a delete operation. Call its ExtractErr 96 // method to determine if the request succeeded or failed. 97 type DeleteResult struct { 98 golangsdk.ErrResult 99 }