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

     1  package instances
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  type GaussDBResponse struct {
     9  	Id     string `json:"id"`
    10  	Status string `json:"status"`
    11  }
    12  
    13  type CreateResponse struct {
    14  	Instance GaussDBResponse `json:"instance"`
    15  }
    16  
    17  type GaussDBInstance struct {
    18  	Id                string   `json:"id"`
    19  	Name              string   `json:"name"`
    20  	Status            string   `json:"status"`
    21  	Type              string   `json:"type"`
    22  	Port              int      `json:"port"`
    23  	VpcId             string   `json:"vpc_id"`
    24  	SubnetId          string   `json:"subnet_id"`
    25  	SecurityGroupId   string   `json:"security_group_id"`
    26  	TimeZone          string   `json:"time_zone"`
    27  	Region            string   `json:"region"`
    28  	FlavorRef         string   `json:"flavor_ref"`
    29  	DbUserName        string   `json:"db_user_name"`
    30  	DiskEncryptionId  string   `json:"disk_encryption_id"`
    31  	DsspoolId         string   `json:"dsspool_id"`
    32  	SwitchStrategy    string   `json:"switch_strategy"`
    33  	MaintenanceWindow string   `json:"maintenance_window"`
    34  	PublicIps         []string `json:"public_ips"`
    35  	PrivateIps        []string `json:"private_ips"`
    36  
    37  	Volume         VolumeOpt         `json:"volume"`
    38  	Ha             HaOpt             `json:"ha"`
    39  	Nodes          []Nodes           `json:"nodes"`
    40  	DataStore      DataStoreOpt      `json:"datastore"`
    41  	BackupStrategy BackupStrategyOpt `json:"backup_strategy"`
    42  
    43  	EnterpriseProjectId string `json:"enterprise_project_id"`
    44  }
    45  
    46  type Nodes struct {
    47  	Id               string `json:"id"`
    48  	Name             string `json:"name"`
    49  	Status           string `json:"status"`
    50  	Role             string `json:"role"`
    51  	AvailabilityZone string `json:"availability_zone"`
    52  }
    53  
    54  type commonResult struct {
    55  	golangsdk.Result
    56  }
    57  
    58  type CreateResult struct {
    59  	commonResult
    60  }
    61  
    62  type UpdateResult struct {
    63  	commonResult
    64  }
    65  
    66  func (r CreateResult) Extract() (*CreateResponse, error) {
    67  	var response CreateResponse
    68  	err := r.ExtractInto(&response)
    69  	return &response, err
    70  }
    71  
    72  type DeleteResult struct {
    73  	commonResult
    74  }
    75  
    76  type DeleteResponse struct {
    77  	JobId string `json:"job_id"`
    78  }
    79  
    80  func (r DeleteResult) Extract() (*DeleteResponse, error) {
    81  	var response DeleteResponse
    82  	err := r.ExtractInto(&response)
    83  	return &response, err
    84  }
    85  
    86  type ListGaussDBResult struct {
    87  	commonResult
    88  }
    89  
    90  type ListGaussDBResponse struct {
    91  	Instances  []GaussDBInstance `json:"instances"`
    92  	TotalCount int               `json:"total_count"`
    93  }
    94  
    95  type GaussDBPage struct {
    96  	pagination.SinglePageBase
    97  }
    98  
    99  func (r GaussDBPage) IsEmpty() (bool, error) {
   100  	data, err := ExtractGaussDBInstances(r)
   101  	if err != nil {
   102  		return false, err
   103  	}
   104  	return len(data.Instances) == 0, err
   105  }
   106  
   107  // ExtractGaussDBInstances is a function that takes a ListResult and returns the services' information.
   108  func ExtractGaussDBInstances(r pagination.Page) (ListGaussDBResponse, error) {
   109  	var s ListGaussDBResponse
   110  	err := (r.(GaussDBPage)).ExtractInto(&s)
   111  	return s, err
   112  }
   113  
   114  type RenameResponse struct {
   115  	Instance GaussDBResponse `json:"instance"`
   116  	JobId    string          `json:"job_id"`
   117  }
   118  
   119  type RenameResult struct {
   120  	commonResult
   121  }
   122  
   123  func (r RenameResult) Extract() (*RenameResponse, error) {
   124  	var response RenameResponse
   125  	err := r.ExtractInto(&response)
   126  	return &response, err
   127  }