github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/networks/results.go (about)

     1  package networks
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  // A Network represents a network in an OpenStack cloud.
     9  type Network struct {
    10  	// The Bridge that VIFs on this network are connected to
    11  	Bridge string `json:"bridge"`
    12  
    13  	// BridgeInterface is what interface is connected to the Bridge
    14  	BridgeInterface string `json:"bridge_interface"`
    15  
    16  	// The Broadcast address of the network.
    17  	Broadcast string `json:"broadcast"`
    18  
    19  	// CIDR is the IPv4 subnet.
    20  	CIDR string `json:"cidr"`
    21  
    22  	// CIDRv6 is the IPv6 subnet.
    23  	CIDRv6 string `json:"cidr_v6"`
    24  
    25  	// CreatedAt is when the network was created..
    26  	CreatedAt golangsdk.JSONRFC3339MilliNoZ `json:"created_at,omitempty"`
    27  
    28  	// Deleted shows if the network has been deleted.
    29  	Deleted bool `json:"deleted"`
    30  
    31  	// DeletedAt is the time when the network was deleted.
    32  	DeletedAt golangsdk.JSONRFC3339MilliNoZ `json:"deleted_at,omitempty"`
    33  
    34  	// DHCPStart is the start of the DHCP address range.
    35  	DHCPStart string `json:"dhcp_start"`
    36  
    37  	// DNS1 is the first DNS server to use through DHCP.
    38  	DNS1 string `json:"dns_1"`
    39  
    40  	// DNS2 is the first DNS server to use through DHCP.
    41  	DNS2 string `json:"dns_2"`
    42  
    43  	// Gateway is the network gateway.
    44  	Gateway string `json:"gateway"`
    45  
    46  	// Gatewayv6 is the IPv6 network gateway.
    47  	Gatewayv6 string `json:"gateway_v6"`
    48  
    49  	// Host is the host that the network service is running on.
    50  	Host string `json:"host"`
    51  
    52  	// ID is the UUID of the network.
    53  	ID string `json:"id"`
    54  
    55  	// Injected determines if network information is injected into the host.
    56  	Injected bool `json:"injected"`
    57  
    58  	// Label is the common name that the network has..
    59  	Label string `json:"label"`
    60  
    61  	// MultiHost is if multi-host networking is enablec..
    62  	MultiHost bool `json:"multi_host"`
    63  
    64  	// Netmask is the network netmask.
    65  	Netmask string `json:"netmask"`
    66  
    67  	// Netmaskv6 is the IPv6 netmask.
    68  	Netmaskv6 string `json:"netmask_v6"`
    69  
    70  	// Priority is the network interface priority.
    71  	Priority int `json:"priority"`
    72  
    73  	// ProjectID is the project associated with this network.
    74  	ProjectID string `json:"project_id"`
    75  
    76  	// RXTXBase configures bandwidth entitlement.
    77  	RXTXBase int `json:"rxtx_base"`
    78  
    79  	// UpdatedAt is the time when the network was last updated.
    80  	UpdatedAt golangsdk.JSONRFC3339MilliNoZ `json:"updated_at,omitempty"`
    81  
    82  	// VLAN is the vlan this network runs on.
    83  	VLAN int `json:"vlan"`
    84  
    85  	// VPNPrivateAddress is the private address of the CloudPipe VPN.
    86  	VPNPrivateAddress string `json:"vpn_private_address"`
    87  
    88  	// VPNPublicAddress is the public address of the CloudPipe VPN.
    89  	VPNPublicAddress string `json:"vpn_public_address"`
    90  
    91  	// VPNPublicPort is the port of the CloudPipe VPN.
    92  	VPNPublicPort int `json:"vpn_public_port"`
    93  }
    94  
    95  // NetworkPage stores a single page of all Network results from a List call.
    96  type NetworkPage struct {
    97  	pagination.SinglePageBase
    98  }
    99  
   100  // IsEmpty determines whether or not a NetworkPage is empty.
   101  func (page NetworkPage) IsEmpty() (bool, error) {
   102  	va, err := ExtractNetworks(page)
   103  	return len(va) == 0, err
   104  }
   105  
   106  // ExtractNetworks interprets a page of results as a slice of Networks.
   107  func ExtractNetworks(r pagination.Page) ([]Network, error) {
   108  	var s struct {
   109  		Networks []Network `json:"networks"`
   110  	}
   111  	err := (r.(NetworkPage)).ExtractInto(&s)
   112  	return s.Networks, err
   113  }
   114  
   115  type NetworkResult struct {
   116  	golangsdk.Result
   117  }
   118  
   119  // Extract is a method that attempts to interpret any Network resource
   120  // response as a Network struct.
   121  func (r NetworkResult) Extract() (*Network, error) {
   122  	var s struct {
   123  		Network *Network `json:"network"`
   124  	}
   125  	err := r.ExtractInto(&s)
   126  	return s.Network, err
   127  }
   128  
   129  // GetResult is the response from a Get operation. Call its Extract method to
   130  // interpret it as a Network.
   131  type GetResult struct {
   132  	NetworkResult
   133  }