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

     1  package instances
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  	"github.com/chnsz/golangsdk/pagination"
     6  )
     7  
     8  type DataStore struct {
     9  	Type          string `json:"type" required:"true"`
    10  	Version       string `json:"version" required:"true"`
    11  	StorageEngine string `json:"storage_engine" required:"true"`
    12  }
    13  
    14  type Flavor struct {
    15  	Num      string `json:"num"`
    16  	Size     string `json:"size"`
    17  	Storage  string `json:"storage"`
    18  	SpecCode string `json:"spec_code"`
    19  }
    20  
    21  type BackupStrategy struct {
    22  	StartTime string `json:"start_time"`
    23  	KeepDays  int    `json:"keep_days"`
    24  }
    25  
    26  type GeminiDBBase struct {
    27  	Id              string    `json:"id"`
    28  	Name            string    `json:"name"`
    29  	Status          string    `json:"status"`
    30  	Region          string    `json:"region"`
    31  	Mode            string    `json:"mode"`
    32  	Created         string    `json:"-"`
    33  	VpcId           string    `json:"vpc_id"`
    34  	SubnetId        string    `json:"subnet_id"`
    35  	SecurityGroupId string    `json:"security_group_id"`
    36  	DataStore       DataStore `json:"datastore"`
    37  
    38  	EnterpriseProjectId string `json:"enterprise_project_id"`
    39  }
    40  
    41  type CreateResponse struct {
    42  	GeminiDBBase
    43  	JobId            string            `json:"job_id"`
    44  	OrderId          string            `json:"order_id"`
    45  	AvailabilityZone string            `json:"availability_zone"`
    46  	Flavor           []Flavor          `json:"flavor"`
    47  	BackupStrategy   BackupStrategyOpt `json:"backup_strategy"`
    48  }
    49  
    50  type GeminiDBInstance struct {
    51  	GeminiDBBase
    52  	Port              string         `json:"port"`
    53  	Engine            string         `json:"engine"`
    54  	Updated           string         `json:"-"`
    55  	DbUserName        string         `json:"db_user_name"`
    56  	PayMode           string         `json:"pay_mode"`
    57  	TimeZone          string         `json:"time_zone"`
    58  	MaintenanceWindow string         `json:"maintenance_window"`
    59  	LbIpAddress       string         `json:"lb_ip_address"`
    60  	LbPort            string         `json:"lb_port"`
    61  	Actions           []string       `json:"actions"`
    62  	Groups            []Groups       `json:"groups"`
    63  	BackupStrategy    BackupStrategy `json:"backup_strategy"`
    64  
    65  	DedicatedResourceId string `json:"dedicated_resource_id"`
    66  }
    67  
    68  type Groups struct {
    69  	Id     string  `json:"id"`
    70  	Status string  `json:"status"`
    71  	Volume Volume  `json:"volume"`
    72  	Nodes  []Nodes `json:"nodes"`
    73  }
    74  
    75  type Volume struct {
    76  	Size string `json:"size"`
    77  	Used string `json:"used"`
    78  }
    79  
    80  type Nodes struct {
    81  	Id               string `json:"id"`
    82  	Name             string `json:"name"`
    83  	Status           string `json:"status"`
    84  	PrivateIp        string `json:"private_ip"`
    85  	PublicIp         string `json:"public_ip"`
    86  	SpecCode         string `json:"spec_code"`
    87  	AvailabilityZone string `json:"availability_zone"`
    88  	SupportReduce    bool   `json:"support_reduce"`
    89  }
    90  
    91  type commonResult struct {
    92  	golangsdk.Result
    93  }
    94  
    95  type CreateResult struct {
    96  	commonResult
    97  }
    98  
    99  func (r CreateResult) Extract() (*CreateResponse, error) {
   100  	var response CreateResponse
   101  	err := r.ExtractInto(&response)
   102  	return &response, err
   103  }
   104  
   105  type DeleteResult struct {
   106  	commonResult
   107  }
   108  
   109  type DeleteResponse struct {
   110  	JobId string `json:"job_id"`
   111  }
   112  
   113  func (r DeleteResult) Extract() (*DeleteResponse, error) {
   114  	var response DeleteResponse
   115  	err := r.ExtractInto(&response)
   116  	return &response, err
   117  }
   118  
   119  type ExtendResult struct {
   120  	commonResult
   121  }
   122  
   123  type ExtendResponse struct {
   124  	JobId   string `json:"job_id"`
   125  	OrderId string `json:"order_id"`
   126  }
   127  
   128  func (r ExtendResult) Extract() (*ExtendResponse, error) {
   129  	var response ExtendResponse
   130  	err := r.ExtractInto(&response)
   131  	return &response, err
   132  }
   133  
   134  type UpdateResult struct {
   135  	golangsdk.ErrResult
   136  }
   137  
   138  type ListGeminiDBResult struct {
   139  	commonResult
   140  }
   141  
   142  type ListGeminiDBResponse struct {
   143  	Instances  []GeminiDBInstance `json:"instances"`
   144  	TotalCount int                `json:"total_count"`
   145  }
   146  
   147  type GeminiDBPage struct {
   148  	pagination.SinglePageBase
   149  }
   150  
   151  func (r GeminiDBPage) IsEmpty() (bool, error) {
   152  	data, err := ExtractGeminiDBInstances(r)
   153  	if err != nil {
   154  		return false, err
   155  	}
   156  	return len(data.Instances) == 0, err
   157  }
   158  
   159  // ExtractGeminiDBInstances is a function that takes a ListResult and returns the services' information.
   160  func ExtractGeminiDBInstances(r pagination.Page) (ListGeminiDBResponse, error) {
   161  	var s ListGeminiDBResponse
   162  	err := (r.(GeminiDBPage)).ExtractInto(&s)
   163  	return s, err
   164  }
   165  
   166  type DehResource struct {
   167  	Id               string   `json:"id"`
   168  	ResourceName     string   `json:"resource_name"`
   169  	EngineName       string   `json:"engine_name"`
   170  	AvailabilityZone string   `json:"availability_zone"`
   171  	Architecture     string   `json:"architecture"`
   172  	Status           string   `json:"status"`
   173  	Capacity         Capacity `json:"capacity"`
   174  }
   175  
   176  type Capacity struct {
   177  	Vcpus  int   `json:"vcpus"`
   178  	Ram    int   `json:"ram"`
   179  	Volume int64 `json:"volume"`
   180  }
   181  
   182  type ListDehResponse struct {
   183  	Resources  []DehResource `json:"resources"`
   184  	TotalCount int           `json:"total_count"`
   185  }
   186  
   187  type DehResourcePage struct {
   188  	pagination.SinglePageBase
   189  }
   190  
   191  func ExtractDehResources(r pagination.Page) (ListDehResponse, error) {
   192  	var s ListDehResponse
   193  	err := (r.(DehResourcePage)).ExtractInto(&s)
   194  	return s, err
   195  }
   196  
   197  type SslResult struct {
   198  	commonResult
   199  }
   200  
   201  type SslResponse struct {
   202  	JobId string `json:"job_id"`
   203  }
   204  
   205  func (r SslResult) Extract() (*SslResponse, error) {
   206  	var response SslResponse
   207  	err := r.ExtractInto(&response)
   208  	return &response, err
   209  }
   210  
   211  type PublicIpResult struct {
   212  	commonResult
   213  }
   214  
   215  type PublicIpResponse struct {
   216  	JobId string `json:"job_id"`
   217  }
   218  
   219  func (r PublicIpResult) Extract() (*PublicIpResponse, error) {
   220  	var response PublicIpResponse
   221  	err := r.ExtractInto(&response)
   222  	return &response, err
   223  }