github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/dms/v2/kafka/instances/results.go (about) 1 package instances 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 "github.com/chnsz/golangsdk/openstack/common/tags" 6 "github.com/chnsz/golangsdk/pagination" 7 ) 8 9 // InstanceCreate response 10 type InstanceCreate struct { 11 InstanceID string `json:"instance_id"` 12 } 13 14 // CreateResult is a struct that contains all the return parameters of creation 15 type CreateResult struct { 16 golangsdk.Result 17 } 18 19 // Extract from CreateResult 20 func (r CreateResult) Extract() (*InstanceCreate, error) { 21 var s InstanceCreate 22 err := r.Result.ExtractInto(&s) 23 return &s, err 24 } 25 26 // DeleteResult is a struct which contains the result of deletion 27 type DeleteResult struct { 28 golangsdk.ErrResult 29 } 30 31 type ListResponse struct { 32 Instances []Instance `json:"instances"` 33 TotalCount int `json:"instance_num"` 34 } 35 36 // Instance response 37 type Instance struct { 38 Name string `json:"name"` 39 Description string `json:"description"` 40 Engine string `json:"engine"` 41 EngineVersion string `json:"engine_version"` 42 Specification string `json:"specification"` 43 StorageSpace int `json:"storage_space"` 44 PartitionNum string `json:"partition_num"` 45 BrokerNum int `json:"broker_num"` 46 NodeNum int `json:"node_num"` 47 UsedStorageSpace int `json:"used_storage_space"` 48 ConnectAddress string `json:"connect_address"` 49 Port int `json:"port"` 50 Status string `json:"status"` 51 InstanceID string `json:"instance_id"` 52 ResourceSpecCode string `json:"resource_spec_code"` 53 ChargingMode int `json:"charging_mode"` 54 VPCID string `json:"vpc_id"` 55 VPCName string `json:"vpc_name"` 56 CreatedAt string `json:"created_at"` 57 UserID string `json:"user_id"` 58 UserName string `json:"user_name"` 59 OrderID string `json:"order_id"` 60 MaintainBegin string `json:"maintain_begin"` 61 MaintainEnd string `json:"maintain_end"` 62 EnablePublicIP bool `json:"enable_publicip"` 63 ManagementConnectAddress string `json:"management_connect_address"` 64 SslEnable bool `json:"ssl_enable"` 65 KafkaSecurityProtocol string `json:"kafka_security_protocol"` 66 SaslEnabledMechanisms []string `json:"sasl_enabled_mechanisms"` 67 EnterpriseProjectID string `json:"enterprise_project_id"` 68 IsLogicalVolume bool `json:"is_logical_volume"` 69 ExtendTimes int `json:"extend_times"` 70 EnableAutoTopic bool `json:"enable_auto_topic"` 71 Type string `json:"type"` 72 ProductID string `json:"product_id"` 73 SecurityGroupID string `json:"security_group_id"` 74 SecurityGroupName string `json:"security_group_name"` 75 SubnetID string `json:"subnet_id"` 76 SubnetName string `json:"subnet_name"` 77 AvailableZones []string `json:"available_zones"` 78 TotalStorageSpace int `json:"total_storage_space"` 79 PublicConnectionAddress string `json:"public_connect_address"` 80 StorageResourceID string `json:"storage_resource_id"` 81 StorageSpecCode string `json:"storage_spec_code"` 82 ServiceType string `json:"service_type"` 83 StorageType string `json:"storage_type"` 84 RetentionPolicy string `json:"retention_policy"` 85 KafkaPublicStatus string `json:"kafka_public_status"` 86 PublicBandWidth int `json:"public_bandwidth"` 87 KafkaManagerUser string `json:"kafka_manager_user"` 88 EnableLogCollect bool `json:"enable_log_collection"` 89 CrossVpcInfo string `json:"cross_vpc_info"` 90 Ipv6Enable bool `json:"ipv6_enable"` 91 Ipv6ConnectAddresses []string `json:"ipv6_connect_addresses"` 92 ConnectorEnalbe bool `json:"connector_enable"` 93 ConnectorID string `json:"connector_id"` 94 RestEnable bool `json:"rest_enable"` 95 RestConnectAddress string `json:"rest_connect_address"` 96 MessageQueryInstEnable bool `json:"message_query_inst_enable"` 97 VpcClientPlain bool `json:"vpc_client_plain"` 98 SupportFeatures string `json:"support_features"` 99 Task Task `json:"task"` 100 TraceEnable bool `json:"trace_enable"` 101 PodConnectAddress string `json:"pod_connect_address"` 102 DiskEncrypted bool `json:"disk_encrypted"` 103 KafkaPrivateConnectAddress string `json:"kafka_private_connect_address"` 104 CesVersion string `json:"ces_version"` 105 AccessUser string `json:"access_user"` 106 Tags []tags.ResourceTag `json:"tags"` 107 } 108 109 type Task struct { 110 Name string `json:"name"` 111 Status string `json:"status"` 112 CreatedAt string `json:"created_at"` 113 } 114 115 // UpdateResult is a struct from which can get the result of update method 116 type UpdateResult struct { 117 golangsdk.Result 118 } 119 120 // GetResult contains the body of getting detailed 121 type GetResult struct { 122 golangsdk.Result 123 } 124 125 // Extract from GetResult 126 func (r GetResult) Extract() (*Instance, error) { 127 var s Instance 128 err := r.Result.ExtractInto(&s) 129 return &s, err 130 } 131 132 type Page struct { 133 pagination.SinglePageBase 134 } 135 136 func (r Page) IsEmpty() (bool, error) { 137 data, err := ExtractInstances(r) 138 if err != nil { 139 return false, err 140 } 141 return len(data.Instances) == 0, err 142 } 143 144 // ExtractCloudServers is a function that takes a ListResult and returns the services' information. 145 func ExtractInstances(r pagination.Page) (ListResponse, error) { 146 var s ListResponse 147 err := (r.(Page)).ExtractInto(&s) 148 return s, err 149 } 150 151 // CrossVpc is the structure that represents the API response of 'UpdateCrossVpc' method. 152 type CrossVpc struct { 153 // The result of cross-VPC access modification. 154 Success bool `json:"success"` 155 // The result list of broker cross-VPC access modification. 156 Connections []Connection `json:"results"` 157 } 158 159 // Connection is the structure that represents the detail of the cross-VPC access. 160 type Connection struct { 161 // advertised.listeners IP/domain name. 162 AdvertisedIp string `json:"advertised_ip"` 163 // The status of broker cross-VPC access modification. 164 Success bool `json:"success"` 165 // Listeners IP. 166 ListenersIp string `json:"ip"` 167 } 168 169 // AutoTopicResult is a struct that contains all the return parameters of UpdateAutoTopic function 170 type AutoTopicResult struct { 171 golangsdk.Result 172 } 173 174 // ResetPasswordResult is a struct that contains all the return parameters of ResetPassword function 175 type ResetPasswordResult struct { 176 golangsdk.Result 177 } 178 179 type commonResult struct { 180 golangsdk.Result 181 } 182 183 type ModifyConfigurationResult struct { 184 commonResult 185 } 186 187 type GetConfigurationResult struct { 188 commonResult 189 } 190 191 type RebootResult struct { 192 commonResult 193 } 194 195 type GetTasksResult struct { 196 commonResult 197 } 198 199 type ModifyConfigurationResp struct { 200 JobId string `json:"job_id"` 201 DynamicConfig int `json:"dynamic_config"` 202 StaticConfig int `json:"static_config"` 203 } 204 205 func (r ModifyConfigurationResult) Extract() (*ModifyConfigurationResp, error) { 206 var response ModifyConfigurationResp 207 err := r.ExtractInto(&response) 208 return &response, err 209 } 210 211 type Result struct { 212 Result string `json:"result"` 213 Instance string `json:"instance"` 214 } 215 216 type RebootResp struct { 217 Results []Result `json:"results"` 218 } 219 220 func (r RebootResult) Extract() (*RebootResp, error) { 221 var response RebootResp 222 err := r.ExtractInto(&response) 223 return &response, err 224 } 225 226 type KafkaParam struct { 227 Name string `json:"name"` 228 Value string `json:"value"` 229 DefaultValue string `json:"default_value"` 230 ConfigType string `json:"config_type"` 231 ValidValues string `json:"valid_values"` 232 ValueType string `json:"value_type"` 233 } 234 235 type GetConfigurationResp struct { 236 KafkaConfigs []KafkaParam `json:"kafka_configs"` 237 } 238 239 func (r GetConfigurationResult) Extract() (*GetConfigurationResp, error) { 240 var response GetConfigurationResp 241 err := r.ExtractInto(&response) 242 return &response, err 243 } 244 245 type TaskParams struct { 246 Name string `json:"name"` 247 Params string `json:"params"` 248 Status string `json:"status"` 249 } 250 251 type GetTaskResp struct { 252 Tasks []TaskParams `json:"tasks"` 253 } 254 255 func (r GetTasksResult) Extract() (*GetTaskResp, error) { 256 var response GetTaskResp 257 err := r.ExtractInto(&response) 258 return &response, err 259 }