github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/taurusdb/v3/instances/results.go (about)

     1  package instances
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  	"github.com/chnsz/golangsdk/openstack/common/structs"
     6  	"github.com/chnsz/golangsdk/pagination"
     7  )
     8  
     9  type DataStore struct {
    10  	Type    string `json:"type" required:"true"`
    11  	Version string `json:"version" required:"true"`
    12  }
    13  
    14  type BackupStrategy struct {
    15  	StartTime string `json:"start_time"`
    16  	KeepDays  string `json:"keep_days"`
    17  }
    18  
    19  type TaurusDBResponse struct {
    20  	Id              string `json:"id"`
    21  	Name            string `json:"name"`
    22  	Status          string `json:"status"`
    23  	Region          string `json:"region"`
    24  	Mode            string `json:"mode"`
    25  	Port            string `json:"port"`
    26  	VpcId           string `json:"vpc_id"`
    27  	SubnetId        string `json:"subnet_id"`
    28  	SecurityGroupId string `json:"security_group_id"`
    29  	ConfigurationId string `json:"configuration_id"`
    30  	AZMode          string `json:"availability_zone_mode"`
    31  	MasterAZ        string `json:"master_availability_zone"`
    32  	SlaveCount      int    `json:"slave_count"`
    33  
    34  	DataStore      DataStore          `json:"datastore"`
    35  	BackupStrategy BackupStrategy     `json:"backup_strategy"`
    36  	ChargeInfo     structs.ChargeInfo `json:"charge_info"`
    37  
    38  	EnterpriseProjectId string `json:"enterprise_project_id"`
    39  }
    40  
    41  type CreateResponse struct {
    42  	Instance TaurusDBResponse `json:"instance"`
    43  	JobId    string           `json:"job_id"`
    44  	OrderId  string           `json:"order_id"`
    45  }
    46  
    47  type TaurusDBInstance struct {
    48  	Id              string   `json:"id"`
    49  	Name            string   `json:"name"`
    50  	Status          string   `json:"status"`
    51  	Type            string   `json:"type"`
    52  	Port            string   `json:"port"`
    53  	NodeCount       int      `json:"node_count"`
    54  	VpcId           string   `json:"vpc_id"`
    55  	SubnetId        string   `json:"subnet_id"`
    56  	SecurityGroupId string   `json:"security_group_id"`
    57  	ConfigurationId string   `json:"configuration_id"`
    58  	AZMode          string   `json:"az_mode"`
    59  	MasterAZ        string   `json:"master_az_code"`
    60  	TimeZone        string   `json:"time_zone"`
    61  	ProjectId       string   `json:"project_id"`
    62  	DbUserName      string   `json:"db_user_name"`
    63  	PublicIps       string   `json:"public_ips"`
    64  	PrivateIps      []string `json:"private_write_ips"`
    65  	Created         string   `json:"-"`
    66  	Updated         string   `json:"-"`
    67  
    68  	Volume         Volume         `json:"volume"`
    69  	Nodes          []Nodes        `json:"nodes"`
    70  	DataStore      DataStore      `json:"datastore"`
    71  	BackupStrategy BackupStrategy `json:"backup_strategy"`
    72  
    73  	EnterpriseProjectId string `json:"enterprise_project_id"`
    74  	DedicatedResourceId string `json:"dedicated_resource_id"`
    75  }
    76  
    77  type ListTaurusDBInstance struct {
    78  	Id              string   `json:"id"`
    79  	Name            string   `json:"name"`
    80  	Status          string   `json:"status"`
    81  	Type            string   `json:"type"`
    82  	Port            string   `json:"port"`
    83  	NodeCount       int      `json:"node_count"`
    84  	VpcId           string   `json:"vpc_id"`
    85  	SubnetId        string   `json:"subnet_id"`
    86  	SecurityGroupId string   `json:"security_group_id"`
    87  	ConfigurationId string   `json:"configuration_id"`
    88  	AZMode          string   `json:"az_mode"`
    89  	MasterAZ        string   `json:"master_az_code"`
    90  	TimeZone        string   `json:"time_zone"`
    91  	ProjectId       string   `json:"project_id"`
    92  	DbUserName      string   `json:"db_user_name"`
    93  	PublicIps       []string `json:"public_ips"`
    94  	PrivateIps      []string `json:"private_write_ips"`
    95  	Created         string   `json:"-"`
    96  	Updated         string   `json:"-"`
    97  
    98  	Volume         Volume         `json:"volume"`
    99  	Nodes          []Nodes        `json:"nodes"`
   100  	DataStore      DataStore      `json:"datastore"`
   101  	BackupStrategy BackupStrategy `json:"backup_strategy"`
   102  
   103  	EnterpriseProjectId string `json:"enterprise_project_id"`
   104  	DedicatedResourceId string `json:"dedicated_resource_id"`
   105  }
   106  
   107  type Volume struct {
   108  	Type string `json:"type"`
   109  	Used string `json:"used"`
   110  }
   111  
   112  type NodeVolume struct {
   113  	Size int `json:"size"`
   114  }
   115  
   116  type Nodes struct {
   117  	Id               string     `json:"id"`
   118  	Name             string     `json:"name"`
   119  	Type             string     `json:"type"`
   120  	Status           string     `json:"status"`
   121  	PrivateIps       []string   `json:"private_read_ips"`
   122  	Port             int        `json:"port"`
   123  	Flavor           string     `json:"flavor_ref"`
   124  	Region           string     `json:"region_code"`
   125  	AvailabilityZone string     `json:"az_code"`
   126  	Volume           NodeVolume `json:"volume"`
   127  }
   128  
   129  type commonResult struct {
   130  	golangsdk.Result
   131  }
   132  
   133  type CreateResult struct {
   134  	commonResult
   135  }
   136  
   137  func (r CreateResult) Extract() (*CreateResponse, error) {
   138  	var response CreateResponse
   139  	err := r.ExtractInto(&response)
   140  	return &response, err
   141  }
   142  
   143  type DeleteResult struct {
   144  	commonResult
   145  }
   146  
   147  type DeleteResponse struct {
   148  	JobId string `json:"job_id"`
   149  }
   150  
   151  func (r DeleteResult) Extract() (*DeleteResponse, error) {
   152  	var response DeleteResponse
   153  	err := r.ExtractInto(&response)
   154  	return &response, err
   155  }
   156  
   157  type GetResult struct {
   158  	commonResult
   159  }
   160  
   161  func (r GetResult) Extract() (*TaurusDBInstance, error) {
   162  	var instance TaurusDBInstance
   163  	err := r.ExtractIntoStructPtr(&instance, "instance")
   164  	return &instance, err
   165  }
   166  
   167  type ExtendResult struct {
   168  	golangsdk.ErrResult
   169  }
   170  
   171  type ListTaurusDBResult struct {
   172  	commonResult
   173  }
   174  
   175  type ListTaurusDBResponse struct {
   176  	Instances  []ListTaurusDBInstance `json:"instances"`
   177  	TotalCount int                    `json:"total_count"`
   178  }
   179  
   180  type TaurusDBPage struct {
   181  	pagination.SinglePageBase
   182  }
   183  
   184  func (r TaurusDBPage) IsEmpty() (bool, error) {
   185  	data, err := ExtractTaurusDBInstances(r)
   186  	if err != nil {
   187  		return false, err
   188  	}
   189  	return len(data.Instances) == 0, err
   190  }
   191  
   192  // ExtractTaurusDBInstances is a function that takes a ListResult and returns the services' information.
   193  func ExtractTaurusDBInstances(r pagination.Page) (ListTaurusDBResponse, error) {
   194  	var s ListTaurusDBResponse
   195  	err := (r.(TaurusDBPage)).ExtractInto(&s)
   196  	return s, err
   197  }
   198  
   199  type Proxy struct {
   200  	Address string `json:"address"`
   201  	Port    int    `json:"port"`
   202  	ElbVip  string `json:"elb_vip"`
   203  	Eip     string `json:"eip"`
   204  	NodeNum int    `json:"node_num"`
   205  	Flavor  string `json:"flavor_ref"`
   206  }
   207  
   208  type GetProxyResult struct {
   209  	commonResult
   210  }
   211  
   212  func (r GetProxyResult) Extract() (*Proxy, error) {
   213  	var proxy Proxy
   214  	err := r.ExtractIntoStructPtr(&proxy, "proxy")
   215  	return &proxy, err
   216  }
   217  
   218  type DehResource struct {
   219  	Id               string   `json:"id"`
   220  	ResourceName     string   `json:"resource_name"`
   221  	EngineName       string   `json:"engine_name"`
   222  	AvailabilityZone []string `json:"availability_zone"`
   223  	Architecture     string   `json:"architecture"`
   224  	Status           string   `json:"status"`
   225  	Capacity         Capacity `json:"capacity"`
   226  }
   227  
   228  type Capacity struct {
   229  	Vcpus  int   `json:"vcpus"`
   230  	Ram    int   `json:"ram"`
   231  	Volume int64 `json:"volume"`
   232  }
   233  
   234  type ListDehResponse struct {
   235  	Resources  []DehResource `json:"resources"`
   236  	TotalCount int           `json:"total_count"`
   237  }
   238  
   239  type DehResourcePage struct {
   240  	pagination.SinglePageBase
   241  }
   242  
   243  func ExtractDehResources(r pagination.Page) (ListDehResponse, error) {
   244  	var s ListDehResponse
   245  	err := (r.(DehResourcePage)).ExtractInto(&s)
   246  	return s, err
   247  }