github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/iec/v1/servers/result.go (about)

     1  package servers
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers"
     6  	"github.com/huaweicloud/golangsdk/openstack/iec/v1/common"
     7  )
     8  
     9  // GetResult contains the server result
    10  type GetResult struct {
    11  	golangsdk.Result
    12  }
    13  
    14  type ServerDetail struct {
    15  	Server *Server `json:"server"`
    16  }
    17  
    18  // Server IEC服务实例的对外呈现结构
    19  type Server struct {
    20  	cloudservers.CloudServer
    21  	CommonFiled
    22  }
    23  
    24  //CommonFiled is common filed
    25  type CommonFiled struct {
    26  	ServerID      string             `json:"origin_server_id,omitempty"`
    27  	EdgeCloudID   string             `json:"edgecloud_id,omitempty"`
    28  	EdgeCloudName string             `json:"edgecloud_name,omitempty"`
    29  	Location      common.GeoLocation `json:"geolocation"`
    30  	Operator      common.Operator    `json:"operator"`
    31  	DomainID      string             `json:"domain_id"`
    32  }
    33  
    34  // ExtractServerDetail 输出边缘实例详情
    35  func (r GetResult) ExtractServerDetail() (ServerDetail, error) {
    36  	var serverDetail ServerDetail
    37  	err := r.ExtractInto(&serverDetail)
    38  	return serverDetail, err
    39  }
    40  
    41  // UpdateResult contains the update result
    42  type UpdateResult struct {
    43  	golangsdk.Result
    44  }
    45  
    46  // ExtractUpdateToServer extract CloudServer struct from UpdateResult
    47  func (r UpdateResult) ExtractUpdateToServer() (interface{}, error) {
    48  	var updateServer Server
    49  	err := r.ExtractInto(&updateServer)
    50  	return &updateServer, err
    51  }
    52  
    53  type commonResult struct {
    54  	golangsdk.Result
    55  }
    56  
    57  type CreateResult struct {
    58  	commonResult
    59  }
    60  
    61  type JobExecResult struct {
    62  	commonResult
    63  }
    64  
    65  // Job 执行创建/删除接口时返回的jobid结构
    66  type Job struct {
    67  	// job id of create image
    68  	Id string `json:"job_id"`
    69  }
    70  
    71  func (r commonResult) ExtractJob() (Job, error) {
    72  	var j Job
    73  	err := r.ExtractInto(&j)
    74  	return j, err
    75  }
    76  
    77  // ServerIDs is a serverIds structure returned when you create a server
    78  type ServerIDs struct {
    79  	IDs []string `json:"server_ids"`
    80  }
    81  
    82  //ExtractServer is used to extract server struct in response
    83  func (r commonResult) ExtractServer() (ServerIDs, error) {
    84  	var s ServerIDs
    85  	err := r.ExtractInto(&s)
    86  	return s, err
    87  }
    88  
    89  //CreateCloudServerResponse is a structure for creating server return values
    90  type CreateCloudServerResponse struct {
    91  	Job       Job
    92  	ServerIDs ServerIDs
    93  }
    94  
    95  // DeleteResult is the response from a Delete operation. Call its ExtractErr
    96  // method to determine if the call succeeded or failed.
    97  type DeleteResult struct {
    98  	golangsdk.ErrResult
    99  }
   100  
   101  type Servers struct {
   102  	Servers []Server `json:"servers"`
   103  	Count   int      `json:"count"`
   104  }
   105  
   106  type ListResult struct {
   107  	commonResult
   108  }
   109  
   110  func (r ListResult) Extract() (*Servers, error) {
   111  	var entity Servers
   112  
   113  	err := r.ExtractInto(&entity)
   114  	return &entity, err
   115  }