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

     1  package publicips
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/openstack/iec/v1/common"
     6  	"github.com/huaweicloud/golangsdk/pagination"
     7  )
     8  
     9  type CommonPublicIP struct {
    10  	// Specifies the ID of the elastic IP address, which uniquely
    11  	// identifies the elastic IP address.
    12  	ID string `json:"id"`
    13  
    14  	// Specifies the status of the elastic IP address.
    15  	Status string `json:"status"`
    16  
    17  	// Specifies the obtained elastic IP address.
    18  	PublicIpAddress string `json:"public_ip_address"`
    19  
    20  	// Value range: 4, 6, respectively, to create ipv4 and ipv6, when not created ipv4 by default
    21  	IPVersion int `json:"ip_version"`
    22  
    23  	// Specifies the time for applying for the elastic IP address.
    24  	CreateTime string `json:"create_time"`
    25  
    26  	// Specifies the Siteid.
    27  	SiteID string `json:"site_id"`
    28  
    29  	// SiteInfo
    30  	SiteInfo string `json:"site_info"`
    31  
    32  	//Operator information
    33  	Operator common.Operator `json:"operator"`
    34  }
    35  
    36  type PublicIPCreateResp struct {
    37  	CommonPublicIP
    38  
    39  	// Specifies the bandwidth size.
    40  	BandwidthSize int `json:"bandwidth_size"`
    41  
    42  	Region string `json:"region,omitempty"`
    43  }
    44  
    45  type PublicIPUpdateResp struct {
    46  	CommonPublicIP
    47  
    48  	// Specifies the private IP address bound to the elastic IP address.
    49  	PrivateIpAddress string `json:"private_ip_address"`
    50  
    51  	// Specifies the port ID.
    52  	PortID string `json:"port_id"`
    53  
    54  	// Specifies the bandwidth size.
    55  	BandwidthSize int `json:"bandwidth_size"`
    56  
    57  	// Specifies the bandwidth ID of the elastic IP address.
    58  	BandwidthID string `json:"bandwidth_id"`
    59  
    60  	// Specifies whether the bandwidth is shared or exclusive.
    61  	BandwidthShareType string `json:"bandwidth_share_type"`
    62  
    63  	// Specifies the bandwidth name.
    64  	BandwidthName string `json:"bandwidth_name"`
    65  }
    66  
    67  type commonResult struct {
    68  	golangsdk.Result
    69  }
    70  
    71  type CreateResult struct {
    72  	commonResult
    73  }
    74  
    75  func (r CreateResult) Extract() (*PublicIPCreateResp, error) {
    76  	var entity PublicIPCreateResp
    77  	err := r.ExtractIntoStructPtr(&entity, "publicip")
    78  	return &entity, err
    79  }
    80  
    81  type DeleteResult struct {
    82  	golangsdk.ErrResult
    83  }
    84  
    85  type GetResult struct {
    86  	commonResult
    87  }
    88  
    89  func (r GetResult) Extract() (*common.PublicIP, error) {
    90  	var entity common.PublicIP
    91  	err := r.ExtractIntoStructPtr(&entity, "publicip")
    92  	return &entity, err
    93  }
    94  
    95  type PublicIPPage struct {
    96  	pagination.LinkedPageBase
    97  }
    98  
    99  func ExtractPublicIPs(r pagination.Page) ([]common.PublicIP, error) {
   100  	var s struct {
   101  		PublicIPs []common.PublicIP `json:"publicips"`
   102  	}
   103  	err := r.(PublicIPPage).ExtractInto(&s)
   104  	return s.PublicIPs, err
   105  }
   106  
   107  // IsEmpty checks whether a NetworkPage struct is empty.
   108  func (r PublicIPPage) IsEmpty() (bool, error) {
   109  	s, err := ExtractPublicIPs(r)
   110  	return len(s) == 0, err
   111  }
   112  
   113  type UpdateResult struct {
   114  	commonResult
   115  }
   116  
   117  func (r UpdateResult) Extract() (*PublicIPUpdateResp, error) {
   118  	var entity PublicIPUpdateResp
   119  	err := r.ExtractIntoStructPtr(&entity, "publicip")
   120  	return &entity, err
   121  }
   122  
   123  // PublicIPs 弹性公网ip列表对象
   124  type PublicIPs struct {
   125  	PublicIPs []common.PublicIP `json:"publicips"`
   126  	Count     int               `json:"count"`
   127  }
   128  
   129  type ListResult struct {
   130  	commonResult
   131  }
   132  
   133  func (r ListResult) Extract() (*PublicIPs, error) {
   134  	var entity PublicIPs
   135  	err := r.ExtractIntoStructPtr(&entity, "")
   136  	return &entity, err
   137  }