github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/taurusdb/v3/instances/results.go (about)

     1  package instances
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/openstack/common/structs"
     6  	"github.com/huaweicloud/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 Volume struct {
    78  	Type string `json:"type"`
    79  	Used string `json:"used"`
    80  }
    81  
    82  type NodeVolume struct {
    83  	Size int `json:"size"`
    84  }
    85  
    86  type Nodes struct {
    87  	Id               string     `json:"id"`
    88  	Name             string     `json:"name"`
    89  	Type             string     `json:"type"`
    90  	Status           string     `json:"status"`
    91  	PrivateIps       []string   `json:"private_read_ips"`
    92  	Port             int        `json:"port"`
    93  	Flavor           string     `json:"flavor_ref"`
    94  	Region           string     `json:"region_code"`
    95  	AvailabilityZone string     `json:"az_code"`
    96  	Volume           NodeVolume `json:"volume"`
    97  }
    98  
    99  type commonResult struct {
   100  	golangsdk.Result
   101  }
   102  
   103  type CreateResult struct {
   104  	commonResult
   105  }
   106  
   107  func (r CreateResult) Extract() (*CreateResponse, error) {
   108  	var response CreateResponse
   109  	err := r.ExtractInto(&response)
   110  	return &response, err
   111  }
   112  
   113  type DeleteResult struct {
   114  	commonResult
   115  }
   116  
   117  type DeleteResponse struct {
   118  	JobId string `json:"job_id"`
   119  }
   120  
   121  func (r DeleteResult) Extract() (*DeleteResponse, error) {
   122  	var response DeleteResponse
   123  	err := r.ExtractInto(&response)
   124  	return &response, err
   125  }
   126  
   127  type GetResult struct {
   128  	commonResult
   129  }
   130  
   131  func (r GetResult) Extract() (*TaurusDBInstance, error) {
   132  	var instance TaurusDBInstance
   133  	err := r.ExtractIntoStructPtr(&instance, "instance")
   134  	return &instance, err
   135  }
   136  
   137  type ExtendResult struct {
   138  	golangsdk.ErrResult
   139  }
   140  
   141  type ListTaurusDBResult struct {
   142  	commonResult
   143  }
   144  
   145  type ListTaurusDBResponse struct {
   146  	Instances  []TaurusDBInstance `json:"instances"`
   147  	TotalCount int                `json:"total_count"`
   148  }
   149  
   150  type TaurusDBPage struct {
   151  	pagination.SinglePageBase
   152  }
   153  
   154  func (r TaurusDBPage) IsEmpty() (bool, error) {
   155  	data, err := ExtractTaurusDBInstances(r)
   156  	if err != nil {
   157  		return false, err
   158  	}
   159  	return len(data.Instances) == 0, err
   160  }
   161  
   162  // ExtractTaurusDBInstances is a function that takes a ListResult and returns the services' information.
   163  func ExtractTaurusDBInstances(r pagination.Page) (ListTaurusDBResponse, error) {
   164  	var s ListTaurusDBResponse
   165  	err := (r.(TaurusDBPage)).ExtractInto(&s)
   166  	return s, err
   167  }
   168  
   169  type Proxy struct {
   170  	Address string `json:"address"`
   171  	Port    int    `json:"port"`
   172  	ElbVip  string `json:"elb_vip"`
   173  	Eip     string `json:"eip"`
   174  	NodeNum int    `json:"node_num"`
   175  	Flavor  string `json:"flavor_ref"`
   176  }
   177  
   178  type GetProxyResult struct {
   179  	commonResult
   180  }
   181  
   182  func (r GetProxyResult) Extract() (*Proxy, error) {
   183  	var proxy Proxy
   184  	err := r.ExtractIntoStructPtr(&proxy, "proxy")
   185  	return &proxy, err
   186  }
   187  
   188  type DehResource struct {
   189  	Id               string   `json:"id"`
   190  	ResourceName     string   `json:"resource_name"`
   191  	EngineName       string   `json:"engine_name"`
   192  	AvailabilityZone []string `json:"availability_zone"`
   193  	Architecture     string   `json:"architecture"`
   194  	Status           string   `json:"status"`
   195  	Capacity         Capacity `json:"capacity"`
   196  }
   197  
   198  type Capacity struct {
   199  	Vcpus  int   `json:"vcpus"`
   200  	Ram    int   `json:"ram"`
   201  	Volume int64 `json:"volume"`
   202  }
   203  
   204  type ListDehResponse struct {
   205  	Resources  []DehResource `json:"resources"`
   206  	TotalCount int           `json:"total_count"`
   207  }
   208  
   209  type DehResourcePage struct {
   210  	pagination.SinglePageBase
   211  }
   212  
   213  func ExtractDehResources(r pagination.Page) (ListDehResponse, error) {
   214  	var s ListDehResponse
   215  	err := (r.(DehResourcePage)).ExtractInto(&s)
   216  	return s, err
   217  }