github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/dms/v2/rabbitmq/instances/results.go (about)

     1  package instances
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/openstack/common/tags"
     6  	"github.com/huaweicloud/golangsdk/pagination"
     7  )
     8  
     9  // InstanceCreate response
    10  type InstanceCreate struct {
    11  	InstanceID string `json:"instance_id"`
    12  }
    13  
    14  // CreateResult is a struct that contains all the return parameters of creation
    15  type CreateResult struct {
    16  	golangsdk.Result
    17  }
    18  
    19  // Extract from CreateResult
    20  func (r CreateResult) Extract() (*InstanceCreate, error) {
    21  	var s InstanceCreate
    22  	err := r.Result.ExtractInto(&s)
    23  	return &s, err
    24  }
    25  
    26  // DeleteResult is a struct which contains the result of deletion
    27  type DeleteResult struct {
    28  	golangsdk.ErrResult
    29  }
    30  
    31  type ListResponse struct {
    32  	Instances  []Instance `json:"instances"`
    33  	TotalCount int        `json:"instance_num"`
    34  }
    35  
    36  // Instance response
    37  type Instance struct {
    38  	Name                     string             `json:"name"`
    39  	Description              string             `json:"description"`
    40  	Engine                   string             `json:"engine"`
    41  	EngineVersion            string             `json:"engine_version"`
    42  	Specification            string             `json:"specification"`
    43  	StorageSpace             int                `json:"storage_space"`
    44  	UsedStorageSpace         int                `json:"used_storage_space"`
    45  	ConnectAddress           string             `json:"connect_address"`
    46  	Port                     int                `json:"port"`
    47  	Status                   string             `json:"status"`
    48  	InstanceID               string             `json:"instance_id"`
    49  	ResourceSpecCode         string             `json:"resource_spec_code"`
    50  	ChargingMode             int                `json:"charging_mode"`
    51  	VPCID                    string             `json:"vpc_id"`
    52  	VPCName                  string             `json:"vpc_name"`
    53  	CreatedAt                string             `json:"created_at"`
    54  	UserID                   string             `json:"user_id"`
    55  	UserName                 string             `json:"user_name"`
    56  	OrderID                  string             `json:"order_id"`
    57  	MaintainBegin            string             `json:"maintain_begin"`
    58  	MaintainEnd              string             `json:"maintain_end"`
    59  	EnablePublicIP           bool               `json:"enable_publicip"`
    60  	PublicIPAddress          string             `json:"publicip_address"`
    61  	PublicIPID               string             `json:"publicip_id"`
    62  	ManagementConnectAddress string             `json:"management_connect_address"`
    63  	SslEnable                bool               `json:"ssl_enable"`
    64  	EnterpriseProjectID      string             `json:"enterprise_project_id"`
    65  	IsLogicalVolume          bool               `json:"is_logical_volume"`
    66  	ExtendTimes              int                `json:"extend_times"`
    67  	Type                     string             `json:"type"`
    68  	ProductID                string             `json:"product_id"`
    69  	SecurityGroupID          string             `json:"security_group_id"`
    70  	SecurityGroupName        string             `json:"security_group_name"`
    71  	SubnetID                 string             `json:"subnet_id"`
    72  	AvailableZones           []string           `json:"available_zones"`
    73  	TotalStorageSpace        int                `json:"total_storage_space"`
    74  	StorageResourceID        string             `json:"storage_resource_id"`
    75  	StorageSpecCode          string             `json:"storage_spec_code"`
    76  	Ipv6Enable               bool               `json:"ipv6_enable"`
    77  	Ipv6ConnectAddresses     []string           `json:"ipv6_connect_addresses"`
    78  	ServiceType              string             `json:"service_type"`
    79  	StorageType              string             `json:"storage_type"`
    80  	PublicBoundWidth         int                `json:"public_boundwidth"`
    81  	EnableLogCollect         bool               `json:"enable_log_collection"`
    82  	ConnectorEnalbe          bool               `json:"connector_enable"`
    83  	ConnectorID              string             `json:"connector_id"`
    84  	RestEnable               bool               `json:"rest_enable"`
    85  	RestConnectAddress       string             `json:"rest_connect_address"`
    86  	MessageQueryInstEnable   bool               `json:"message_query_inst_enable"`
    87  	VpcClientPlain           bool               `json:"vpc_client_plain"`
    88  	SupportFeatures          string             `json:"support_features"`
    89  	TraceEnable              bool               `json:"trace_enable"`
    90  	DiskEncrypted            bool               `json:"disk_encrypted"`
    91  	CesVersion               string             `json:"ces_version"`
    92  	AccessUser               string             `json:"access_user"`
    93  	Tags                     []tags.ResourceTag `json:"tags"`
    94  }
    95  
    96  // UpdateResult is a struct from which can get the result of update method
    97  type UpdateResult struct {
    98  	golangsdk.Result
    99  }
   100  
   101  // GetResult contains the body of getting detailed
   102  type GetResult struct {
   103  	golangsdk.Result
   104  }
   105  
   106  // Extract from GetResult
   107  func (r GetResult) Extract() (*Instance, error) {
   108  	var s Instance
   109  	err := r.Result.ExtractInto(&s)
   110  	return &s, err
   111  }
   112  
   113  type Page struct {
   114  	pagination.SinglePageBase
   115  }
   116  
   117  func (r Page) IsEmpty() (bool, error) {
   118  	data, err := ExtractInstances(r)
   119  	if err != nil {
   120  		return false, err
   121  	}
   122  	return len(data.Instances) == 0, err
   123  }
   124  
   125  // ExtractCloudServers is a function that takes a ListResult and returns the services' information.
   126  func ExtractInstances(r pagination.Page) (ListResponse, error) {
   127  	var s ListResponse
   128  	err := (r.(Page)).ExtractInto(&s)
   129  	return s, err
   130  }