github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/networking/v2/bandwidths/results.go (about)

     1  package bandwidths
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/pagination"
     6  )
     7  
     8  type Bandwidth struct {
     9  	// Specifies the bandwidth name. The value is a string of 1 to 64
    10  	// characters that can contain letters, digits, underscores (_), and hyphens (-).
    11  	Name string `json:"name"`
    12  
    13  	// Specifies the bandwidth size. The value ranges from 1 Mbit/s to
    14  	// 300 Mbit/s.
    15  	Size int `json:"size"`
    16  
    17  	// Specifies the bandwidth ID, which uniquely identifies the
    18  	// bandwidth.
    19  	ID string `json:"id"`
    20  
    21  	// Specifies whether the bandwidth is shared or exclusive. The
    22  	// value can be PER or WHOLE.
    23  	ShareType string `json:"share_type"`
    24  
    25  	// Specifies the elastic IP address of the bandwidth.  The
    26  	// bandwidth, whose type is set to WHOLE, supports up to 20 elastic IP addresses. The
    27  	// bandwidth, whose type is set to PER, supports only one elastic IP address.
    28  	PublicIpInfo []PublicIpInfo `json:"publicip_info"`
    29  
    30  	// Specifies the tenant ID of the user.
    31  	TenantId string `json:"tenant_id"`
    32  
    33  	// Specifies the bandwidth type.
    34  	BandwidthType string `json:"bandwidth_type"`
    35  
    36  	// Specifies the charging mode (by traffic or by bandwidth).
    37  	ChargeMode string `json:"charge_mode"`
    38  
    39  	// Specifies the billing information.
    40  	BillingInfo string `json:"billing_info"`
    41  
    42  	// Status
    43  	Status string `json:"status"`
    44  
    45  	// CreatedAt is the date when the Bandwidth was created.
    46  	CreatedAt string `json:"created_at"`
    47  
    48  	// UpdatedAt is the date when the last change was made to the Bandwidth.
    49  	UpdatedAt string `json:"updated_at"`
    50  }
    51  
    52  type PublicIpInfo struct {
    53  	// Specifies the tenant ID of the user.
    54  	ID string `json:"publicip_id"`
    55  
    56  	// Specifies the elastic IP address.
    57  	Address string `json:"publicip_address"`
    58  
    59  	// Specifies the elastic IP v6 address.
    60  	AddressV6 string `json:"publicipv6_address"`
    61  
    62  	// Specifies the elastic IP version.
    63  	IPVersion int `json:"ip_version"`
    64  
    65  	// Specifies the elastic IP address type.
    66  	Type string `json:"publicip_type"`
    67  }
    68  
    69  type commonResult struct {
    70  	golangsdk.Result
    71  }
    72  
    73  type CreateResult struct {
    74  	commonResult
    75  }
    76  
    77  type UpdateResult struct {
    78  	commonResult
    79  }
    80  
    81  type GetResult struct {
    82  	commonResult
    83  }
    84  
    85  func (r commonResult) Extract() (*Bandwidth, error) {
    86  	s := new(Bandwidth)
    87  	err := r.ExtractIntoStructPtr(s, "bandwidth")
    88  	if err != nil {
    89  		return nil, err
    90  	}
    91  	return s, nil
    92  }
    93  
    94  type BandwidthPage struct {
    95  	pagination.SinglePageBase
    96  }
    97  
    98  func (r BandwidthPage) IsEmpty() (bool, error) {
    99  	is, err := ExtractBandwidths(r)
   100  	return len(is) == 0, err
   101  }
   102  
   103  func ExtractBandwidths(r pagination.Page) ([]Bandwidth, error) {
   104  	var s []Bandwidth
   105  	err := (r.(BandwidthPage)).ExtractIntoSlicePtr(&s, "bandwidths")
   106  	if err != nil {
   107  		return nil, err
   108  	}
   109  	return s, err
   110  }
   111  
   112  type DeleteResult struct {
   113  	golangsdk.ErrResult
   114  }