github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dms/v1/instances/results.go (about) 1 package instances 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 6 ) 7 8 // InstanceCreate response 9 type InstanceCreate struct { 10 InstanceID string `json:"instance_id"` 11 } 12 13 // CreateResult is a struct that contains all the return parameters of creation 14 type CreateResult struct { 15 golangsdk.Result 16 } 17 18 // Extract from CreateResult 19 func (r CreateResult) Extract() (*InstanceCreate, error) { 20 s := new(InstanceCreate) 21 err := r.ExtractIntoStructPtr(s, "") 22 if err != nil { 23 return nil, err 24 } 25 return s, nil 26 } 27 28 // DeleteResult is a struct which contains the result of deletion 29 type DeleteResult struct { 30 golangsdk.ErrResult 31 } 32 33 type ListDmsResponse struct { 34 Instances []Instance `json:"instances"` 35 TotalCount int `json:"instance_num"` 36 } 37 38 // Instance response 39 type Instance struct { 40 Name string `json:"name"` 41 Engine string `json:"engine"` 42 EngineVersion string `json:"engine_version"` 43 Specification string `json:"specification"` 44 StorageSpace int `json:"storage_space"` 45 PartitionNum string `json:"partition_num"` 46 UsedStorageSpace int `json:"used_storage_space"` 47 ConnectAddress string `json:"connect_address"` 48 Port int `json:"port"` 49 Status string `json:"status"` 50 Description string `json:"description"` 51 InstanceID string `json:"instance_id"` 52 ResourceSpecCode string `json:"resource_spec_code"` 53 Type string `json:"type"` 54 ChargingMode int `json:"charging_mode"` 55 VpcID string `json:"vpc_id"` 56 VpcName string `json:"vpc_name"` 57 CreatedAt string `json:"created_at"` 58 ErrorCode string `json:"error_code"` 59 ProductID string `json:"product_id"` 60 SecurityGroupID string `json:"security_group_id"` 61 SecurityGroupName string `json:"security_group_name"` 62 SubnetID string `json:"subnet_id"` 63 SubnetName string `json:"subnet_name"` 64 SubnetCIDR string `json:"subnet_cidr"` 65 AvailableZones []string `json:"available_zones"` 66 UserID string `json:"user_id"` 67 UserName string `json:"user_name"` 68 AccessUser string `json:"access_user"` 69 TotalStorageSpace int `json:"total_storage_space"` 70 StorageResourceID string `json:"storage_resource_id"` 71 StorageSpecCode string `json:"storage_spec_code"` 72 RetentionPolicy string `json:"retention_policy"` 73 KafkaPublicStatus string `json:"kafka_public_status"` 74 PublicBandwidth int `json:"public_bandwidth"` 75 SslEnable bool `json:"ssl_enable"` 76 ServiceType string `json:"service_type"` 77 StorageType string `json:"storage_type"` 78 OrderID string `json:"order_id"` 79 MaintainBegin string `json:"maintain_begin"` 80 MaintainEnd string `json:"maintain_end"` 81 } 82 83 // UpdateResult is a struct from which can get the result of update method 84 type UpdateResult struct { 85 golangsdk.ErrResult 86 } 87 88 // GetResult contains the body of getting detailed 89 type GetResult struct { 90 golangsdk.Result 91 } 92 93 // Extract from GetResult 94 func (r GetResult) Extract() (*Instance, error) { 95 s := new(Instance) 96 err := r.ExtractIntoStructPtr(s, "") 97 if err != nil { 98 return nil, err 99 } 100 return s, nil 101 } 102 103 type DmsPage struct { 104 pagination.SinglePageBase 105 } 106 107 func (r DmsPage) IsEmpty() (bool, error) { 108 data, err := ExtractDmsInstances(r) 109 if err != nil { 110 return false, err 111 } 112 return len(data.Instances) == 0, err 113 } 114 115 // ExtractDmsInstances is a function that takes a ListResult and returns the services' information. 116 func ExtractDmsInstances(r pagination.Page) (*ListDmsResponse, error) { 117 s := new(ListDmsResponse) 118 err := (r.(DmsPage)).ExtractIntoStructPtr(s, "") 119 if err != nil { 120 return nil, err 121 } 122 return s, nil 123 }