github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/cce/v3/addons/results.go (about) 1 package addons 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 ) 6 7 type ListAddon struct { 8 // API type, fixed value "List" 9 Kind string `json:"kind"` 10 // API version, fixed value "v3" 11 Apiversion string `json:"apiVersion"` 12 // all Node Pools 13 Addons []Addon `json:"items"` 14 } 15 16 type Addon struct { 17 // API type, fixed value Addon 18 Kind string `json:"kind"` 19 // API version, fixed value v3 20 ApiVersion string `json:"apiVersion"` 21 // Metadata of an Addon 22 Metadata MetaData `json:"metadata"` 23 // Specifications of an Addon 24 Spec Spec `json:"spec"` 25 // Status of an Addon 26 Status Status `json:"status"` 27 } 28 29 //Metadata required to create an addon 30 type MetaData struct { 31 // Addon unique name 32 Name string `json:"name"` 33 // Addon unique Id 34 Id string `json:"uid"` 35 // Addon tag, key/value pair format 36 Labels map[string]string `json:"lables"` 37 // Addon annotation, key/value pair format 38 Annotations map[string]string `json:"annotaions"` 39 } 40 41 //Specifications to create an addon 42 type Spec struct { 43 // For the addon version. 44 Version string `json:"version"` 45 // Cluster ID. 46 ClusterID string `json:"clusterID"` 47 // Addon Template Name. 48 AddonTemplateName string `json:"addonTemplateName"` 49 // Addon Template Type. 50 AddonTemplateType string `json:"addonTemplateType"` 51 // Addon Template Labels. 52 AddonTemplateLables []string `json:"addonTemplateLables"` 53 // Addon Description. 54 Description string `json:"description"` 55 // Addon Parameters 56 Values Values `json:"values"` 57 } 58 59 type Status struct { 60 //The state of the addon 61 Status string `json:"status"` 62 //Reasons for the addon to become current 63 Reason string `json:"reason"` 64 //Error Message 65 Message string `json:"message"` 66 //The target versions of the addon 67 TargetVersions []string `json:"targetVersions"` 68 //Current version of the addon 69 CurrentVersion Versions `json:"currentVersion"` 70 } 71 72 type Versions struct { 73 // Version of the addon 74 Version string `json:"version"` 75 // The installing param of the addon 76 Input map[string]interface{} `json:"input"` 77 // Wether it is a stable version 78 Stable bool `json:"stable"` 79 // Translate information 80 Translate map[string]interface{} `json:"translate"` 81 // Supported versions 82 SupportVersions []SupportVersions `json:"supportVersions"` 83 } 84 85 type SupportVersions struct { 86 ClusterType string `json:"clusterType"` 87 ClusterVersion []string `json:"clusterVersion"` 88 } 89 type commonResult struct { 90 golangsdk.Result 91 } 92 93 // Extract is a function that accepts a result and extracts an Addon. 94 func (r commonResult) Extract() (*Addon, error) { 95 var s Addon 96 err := r.ExtractInto(&s) 97 return &s, err 98 } 99 100 // ExtractAddon is a function that accepts a ListOpts struct, which allows you to filter and sort 101 // the returned collection for greater efficiency. 102 func (r commonResult) ExtractAddon() ([]Addon, error) { 103 var s ListAddon 104 err := r.ExtractInto(&s) 105 if err != nil { 106 return nil, err 107 } 108 return s.Addons, nil 109 } 110 111 // ListResult represents the result of a list operation. Call its ExtractAddon 112 // method to interpret it as a Addon. 113 type ListResult struct { 114 commonResult 115 } 116 117 // CreateResult represents the result of a create operation. Call its Extract 118 // method to interpret it as an Addon. 119 type CreateResult struct { 120 commonResult 121 } 122 123 // GetResult represents the result of a get operation. Call its Extract 124 // method to interpret it as an Addon. 125 type GetResult struct { 126 commonResult 127 } 128 129 // UpdateResult represents the result of an update operation. Call its Extract 130 // method to interpret it as an Addon. 131 type UpdataResult struct { 132 commonResult 133 } 134 135 // DeleteResult represents the result of a delete operation. Call its ExtractErr 136 // method to determine if the request succeeded or failed. 137 type DeleteResult struct { 138 golangsdk.ErrResult 139 }