github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/params/network.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package params
     5  
     6  import (
     7  	corenetwork "github.com/juju/juju/core/network"
     8  	"github.com/juju/juju/network"
     9  )
    10  
    11  // -----
    12  // Parameters field types.
    13  // -----
    14  
    15  // Subnet describes a single subnet within a network.
    16  type Subnet struct {
    17  	// CIDR of the subnet in IPv4 or IPv6 notation.
    18  	CIDR string `json:"cidr"`
    19  
    20  	// ProviderId is the provider-specific subnet ID (if applicable).
    21  	ProviderId string `json:"provider-id,omitempty"`
    22  
    23  	// ProviderNetworkId is the id of the network containing this
    24  	// subnet from the provider's perspective. It can be empty if the
    25  	// provider doesn't support distinct networks.
    26  	ProviderNetworkId string `json:"provider-network-id,omitempty"`
    27  
    28  	// ProviderSpaceId is the id of the space containing this subnet
    29  	// from the provider's perspective. It can be empty if the
    30  	// provider doesn't support spaces (in which case all subnets are
    31  	// effectively in the default space).
    32  	ProviderSpaceId string `json:"provider-space-id,omitempty"`
    33  
    34  	// VLANTag needs to be between 1 and 4094 for VLANs and 0 for
    35  	// normal networks. It's defined by IEEE 802.1Q standard.
    36  	VLANTag int `json:"vlan-tag"`
    37  
    38  	// Life is the subnet's life cycle value - Alive means the subnet
    39  	// is in use by one or more machines, Dying or Dead means the
    40  	// subnet is about to be removed.
    41  	Life Life `json:"life"`
    42  
    43  	// SpaceTag is the Juju network space this subnet is associated
    44  	// with.
    45  	SpaceTag string `json:"space-tag"`
    46  
    47  	// Zones contain one or more availability zones this subnet is
    48  	// associated with.
    49  	Zones []string `json:"zones"`
    50  
    51  	// Status returns the status of the subnet, whether it is in use, not
    52  	// in use or terminating.
    53  	Status string `json:"status,omitempty"`
    54  }
    55  
    56  // NetworkRoute describes a special route that should be added for a given
    57  // network interface.
    58  type NetworkRoute struct {
    59  	// DestinationCIDR is the Subnet CIDR of traffic that needs a custom route.
    60  	DestinationCIDR string `json:"destination-cidr"`
    61  	// GatewayIP is the target IP to use as the next-hop when sending traffic to DestinationCIDR
    62  	GatewayIP string `json:"gateway-ip"`
    63  	// Metric is the cost for this particular route.
    64  	Metric int `json:"metric"`
    65  }
    66  
    67  // NetworkConfig describes the necessary information to configure
    68  // a single network interface on a machine. This mostly duplicates
    69  // network.InterfaceInfo type and it's defined here so it can be kept
    70  // separate and stable as definition to ensure proper wire-format for
    71  // the API.
    72  type NetworkConfig struct {
    73  	// DeviceIndex specifies the order in which the network interface
    74  	// appears on the host. The primary interface has an index of 0.
    75  	DeviceIndex int `json:"device-index"`
    76  
    77  	// MACAddress is the network interface's hardware MAC address
    78  	// (e.g. "aa:bb:cc:dd:ee:ff").
    79  	MACAddress string `json:"mac-address"`
    80  
    81  	// CIDR of the network, in 123.45.67.89/24 format.
    82  	CIDR string `json:"cidr"`
    83  
    84  	// MTU is the Maximum Transmission Unit controlling the maximum size of the
    85  	// protocol packats that the interface can pass through. It is only used
    86  	// when > 0.
    87  	MTU int `json:"mtu"`
    88  
    89  	// ProviderId is a provider-specific network interface id.
    90  	ProviderId string `json:"provider-id"`
    91  
    92  	// ProviderSubnetId is a provider-specific subnet id, to which the
    93  	// interface is attached to.
    94  	ProviderSubnetId string `json:"provider-subnet-id"`
    95  
    96  	// ProviderSpaceId is a provider-specific space id, to which the interface
    97  	// is attached to, if known and supported.
    98  	ProviderSpaceId string `json:"provider-space-id"`
    99  
   100  	// ProviderAddressId is the provider-specific id of the assigned address, if
   101  	// supported and known.
   102  	ProviderAddressId string `json:"provider-address-id"`
   103  
   104  	// ProviderVLANId is the provider-specific id of the assigned address's
   105  	// VLAN, if supported and known.
   106  	ProviderVLANId string `json:"provider-vlan-id"`
   107  
   108  	// VLANTag needs to be between 1 and 4094 for VLANs and 0 for
   109  	// normal networks. It's defined by IEEE 802.1Q standard.
   110  	VLANTag int `json:"vlan-tag"`
   111  
   112  	// InterfaceName is the raw OS-specific network device name (e.g.
   113  	// "eth1", even for a VLAN eth1.42 virtual interface).
   114  	InterfaceName string `json:"interface-name"`
   115  
   116  	// ParentInterfaceName is the name of the parent interface to use, if known.
   117  	ParentInterfaceName string `json:"parent-interface-name"`
   118  
   119  	// InterfaceType is the type of the interface.
   120  	InterfaceType string `json:"interface-type"`
   121  
   122  	// Disabled is true when the interface needs to be disabled on the
   123  	// machine, e.g. not to configure it at all or stop it if running.
   124  	Disabled bool `json:"disabled"`
   125  
   126  	// NoAutoStart is true when the interface should not be configured
   127  	// to start automatically on boot. By default and for
   128  	// backwards-compatibility, interfaces are configured to
   129  	// auto-start.
   130  	NoAutoStart bool `json:"no-auto-start,omitempty"`
   131  
   132  	// ConfigType, if set, defines what type of configuration to use.
   133  	// See network.InterfaceConfigType for more info. If not set, for
   134  	// backwards-compatibility, "dhcp" is assumed.
   135  	ConfigType string `json:"config-type,omitempty"`
   136  
   137  	// Address contains an optional static IP address to configure for
   138  	// this network interface. The subnet mask to set will be inferred
   139  	// from the CIDR value.
   140  	Address string `json:"address,omitempty"`
   141  
   142  	// DNSServers contains an optional list of IP addresses and/or
   143  	// hostnames to configure as DNS servers for this network
   144  	// interface.
   145  	DNSServers []string `json:"dns-servers,omitempty"`
   146  
   147  	// DNSServers contains an optional list of IP addresses and/or
   148  	// hostnames to configure as DNS servers for this network
   149  	// interface.
   150  	DNSSearchDomains []string `json:"dns-search-domains,omitempty"`
   151  
   152  	// Gateway address, if set, defines the default gateway to
   153  	// configure for this network interface. For containers this
   154  	// usually (one of) the host address(es).
   155  	GatewayAddress string `json:"gateway-address,omitempty"`
   156  
   157  	// Routes is a list of routes that should be applied when this interface is
   158  	// active.
   159  	Routes []NetworkRoute `json:"routes,omitempty"`
   160  
   161  	// IsDefaultGateway marks an interface that is a default gateway for a machine.
   162  	IsDefaultGateway bool `json:"is-default-gateway,omitempty"`
   163  }
   164  
   165  // DeviceBridgeInfo lists the host device and the expected bridge to be
   166  // created.
   167  type DeviceBridgeInfo struct {
   168  	HostDeviceName string `json:"host-device-name"`
   169  	BridgeName     string `json:"bridge-name"`
   170  	MACAddress     string `json:"mac-address"`
   171  }
   172  
   173  // ProviderInterfaceInfoResults holds the results of a
   174  // GetProviderInterfaceInfo call.
   175  type ProviderInterfaceInfoResults struct {
   176  	Results []ProviderInterfaceInfoResult `json:"results"`
   177  }
   178  
   179  // ProviderInterfaceInfoResult stores the provider interface
   180  // information for one machine, or any error that occurred getting the
   181  // information for that machine.
   182  type ProviderInterfaceInfoResult struct {
   183  	MachineTag string                  `json:"machine-tag"`
   184  	Interfaces []ProviderInterfaceInfo `json:"interfaces"`
   185  	Error      *Error                  `json:"error,omitempty"`
   186  }
   187  
   188  // ProviderInterfaceInfo stores the details needed to identify an
   189  // interface to a provider. It's the params equivalent of
   190  // network.ProviderInterfaceInfo, defined here separately to ensure
   191  // that API structures aren't inadvertently changed by internal
   192  // changes.
   193  type ProviderInterfaceInfo struct {
   194  	InterfaceName string `json:"interface-name"`
   195  	MACAddress    string `json:"mac-address"`
   196  	ProviderId    string `json:"provider-id"`
   197  }
   198  
   199  // Port encapsulates a protocol and port number. It is used in API
   200  // requests/responses. See also network.Port, from/to which this is
   201  // transformed.
   202  type Port struct {
   203  	Protocol string `json:"protocol"`
   204  	Number   int    `json:"number"`
   205  }
   206  
   207  // FromNetworkPort is a convenience helper to create a parameter
   208  // out of the network type, here for Port.
   209  func FromNetworkPort(p corenetwork.Port) Port {
   210  	return Port{
   211  		Protocol: p.Protocol,
   212  		Number:   p.Number,
   213  	}
   214  }
   215  
   216  // NetworkPort is a convenience helper to return the parameter
   217  // as network type, here for Port.
   218  func (p Port) NetworkPort() corenetwork.Port {
   219  	return corenetwork.Port{
   220  		Protocol: p.Protocol,
   221  		Number:   p.Number,
   222  	}
   223  }
   224  
   225  // PortRange represents a single range of ports. It is used in API
   226  // requests/responses. See also network.PortRange, from/to which this is
   227  // transformed.
   228  type PortRange struct {
   229  	FromPort int    `json:"from-port"`
   230  	ToPort   int    `json:"to-port"`
   231  	Protocol string `json:"protocol"`
   232  }
   233  
   234  // FromNetworkPortRange is a convenience helper to create a parameter
   235  // out of the network type, here for PortRange.
   236  func FromNetworkPortRange(pr corenetwork.PortRange) PortRange {
   237  	return PortRange{
   238  		FromPort: pr.FromPort,
   239  		ToPort:   pr.ToPort,
   240  		Protocol: pr.Protocol,
   241  	}
   242  }
   243  
   244  // NetworkPortRange is a convenience helper to return the parameter
   245  // as network type, here for PortRange.
   246  func (pr PortRange) NetworkPortRange() corenetwork.PortRange {
   247  	return corenetwork.PortRange{
   248  		FromPort: pr.FromPort,
   249  		ToPort:   pr.ToPort,
   250  		Protocol: pr.Protocol,
   251  	}
   252  }
   253  
   254  // EntityPort holds an entity's tag, a protocol and a port.
   255  type EntityPort struct {
   256  	Tag      string `json:"tag"`
   257  	Protocol string `json:"protocol"`
   258  	Port     int    `json:"port"`
   259  }
   260  
   261  // EntitiesPorts holds the parameters for making an OpenPort or
   262  // ClosePort on some entities.
   263  type EntitiesPorts struct {
   264  	Entities []EntityPort `json:"entities"`
   265  }
   266  
   267  // EntityPortRange holds an entity's tag, a protocol and a port range.
   268  type EntityPortRange struct {
   269  	Tag      string `json:"tag"`
   270  	Protocol string `json:"protocol"`
   271  	FromPort int    `json:"from-port"`
   272  	ToPort   int    `json:"to-port"`
   273  }
   274  
   275  // EntitiesPortRanges holds the parameters for making an OpenPorts or
   276  // ClosePorts on some entities.
   277  type EntitiesPortRanges struct {
   278  	Entities []EntityPortRange `json:"entities"`
   279  }
   280  
   281  // Address represents the location of a machine, including metadata
   282  // about what kind of location the address describes. It's used in
   283  // the API requests/responses. See also network.Address, from/to
   284  // which this is transformed.
   285  type Address struct {
   286  	Value     string `json:"value"`
   287  	Type      string `json:"type"`
   288  	Scope     string `json:"scope"`
   289  	SpaceName string `json:"space-name,omitempty"`
   290  }
   291  
   292  // FromNetworkAddress is a convenience helper to create a parameter
   293  // out of the network type, here for Address.
   294  func FromNetworkAddress(naddr network.Address) Address {
   295  	return Address{
   296  		Value:     naddr.Value,
   297  		Type:      string(naddr.Type),
   298  		Scope:     string(naddr.Scope),
   299  		SpaceName: string(naddr.SpaceName),
   300  	}
   301  }
   302  
   303  // NetworkAddress is a convenience helper to return the parameter
   304  // as network type, here for Address.
   305  func (addr Address) NetworkAddress() network.Address {
   306  	return network.Address{
   307  		Value:     addr.Value,
   308  		Type:      network.AddressType(addr.Type),
   309  		Scope:     network.Scope(addr.Scope),
   310  		SpaceName: network.SpaceName(addr.SpaceName),
   311  	}
   312  }
   313  
   314  // FromNetworkAddresses is a convenience helper to create a parameter
   315  // out of the network type, here for a slice of Address.
   316  func FromNetworkAddresses(naddrs ...network.Address) []Address {
   317  	addrs := make([]Address, len(naddrs))
   318  	for i, naddr := range naddrs {
   319  		addrs[i] = FromNetworkAddress(naddr)
   320  	}
   321  	return addrs
   322  }
   323  
   324  // NetworkAddresses is a convenience helper to return the parameter
   325  // as network type, here for a slice of Address.
   326  func NetworkAddresses(addrs ...Address) []network.Address {
   327  	naddrs := make([]network.Address, len(addrs))
   328  	for i, addr := range addrs {
   329  		naddrs[i] = addr.NetworkAddress()
   330  	}
   331  	return naddrs
   332  }
   333  
   334  // HostPort associates an address with a port. It's used in
   335  // the API requests/responses. See also network.HostPort, from/to
   336  // which this is transformed.
   337  type HostPort struct {
   338  	Address
   339  	Port int `json:"port"`
   340  }
   341  
   342  // FromNetworkHostPort is a convenience helper to create a parameter
   343  // out of the network type, here for HostPort.
   344  func FromNetworkHostPort(nhp network.HostPort) HostPort {
   345  	return HostPort{FromNetworkAddress(nhp.Address), nhp.Port}
   346  }
   347  
   348  // NetworkHostPort is a convenience helper to return the parameter
   349  // as network type, here for HostPort.
   350  func (hp HostPort) NetworkHostPort() network.HostPort {
   351  	return network.HostPort{hp.Address.NetworkAddress(), hp.Port}
   352  }
   353  
   354  // FromNetworkHostPorts is a helper to create a parameter
   355  // out of the network type, here for a slice of HostPort.
   356  func FromNetworkHostPorts(nhps []network.HostPort) []HostPort {
   357  	hps := make([]HostPort, len(nhps))
   358  	for i, nhp := range nhps {
   359  		hps[i] = FromNetworkHostPort(nhp)
   360  	}
   361  	return hps
   362  }
   363  
   364  // NetworkHostPorts is a convenience helper to return the parameter
   365  // as network type, here for a slice of HostPort.
   366  func NetworkHostPorts(hps []HostPort) []network.HostPort {
   367  	nhps := make([]network.HostPort, len(hps))
   368  	for i, hp := range hps {
   369  		nhps[i] = hp.NetworkHostPort()
   370  	}
   371  	return nhps
   372  }
   373  
   374  // FromNetworkHostsPorts is a helper to create a parameter
   375  // out of the network type, here for a nested slice of HostPort.
   376  func FromNetworkHostsPorts(nhpm [][]network.HostPort) [][]HostPort {
   377  	hpm := make([][]HostPort, len(nhpm))
   378  	for i, nhps := range nhpm {
   379  		hpm[i] = FromNetworkHostPorts(nhps)
   380  	}
   381  	return hpm
   382  }
   383  
   384  // NetworkHostsPorts is a convenience helper to return the parameter
   385  // as network type, here for a nested slice of HostPort.
   386  func NetworkHostsPorts(hpm [][]HostPort) [][]network.HostPort {
   387  	nhpm := make([][]network.HostPort, len(hpm))
   388  	for i, hps := range hpm {
   389  		nhpm[i] = NetworkHostPorts(hps)
   390  	}
   391  	return nhpm
   392  }
   393  
   394  // TODO (wpk) Uniter.NetworkConfig API is obsolete, use NetworkInfo instead
   395  // UnitsNetworkConfig holds the parameters for calling Uniter.NetworkConfig()
   396  // API. We need to retain until V4 of the Uniter API is removed.
   397  type UnitsNetworkConfig struct {
   398  	Args []UnitNetworkConfig `json:"args"`
   399  }
   400  
   401  // UnitNetworkConfig holds a unit tag and an endpoint binding name.
   402  type UnitNetworkConfig struct {
   403  	UnitTag     string `json:"unit-tag"`
   404  	BindingName string `json:"binding-name"`
   405  }
   406  
   407  // MachineAddresses holds an machine tag and addresses.
   408  type MachineAddresses struct {
   409  	Tag       string    `json:"tag"`
   410  	Addresses []Address `json:"addresses"`
   411  }
   412  
   413  // SetMachinesAddresses holds the parameters for making an
   414  // API call to update machine addresses.
   415  type SetMachinesAddresses struct {
   416  	MachineAddresses []MachineAddresses `json:"machine-addresses"`
   417  }
   418  
   419  // SetMachineNetworkConfig holds the parameters for making an API call to update
   420  // machine network config.
   421  type SetMachineNetworkConfig struct {
   422  	Tag    string          `json:"tag"`
   423  	Config []NetworkConfig `json:"config"`
   424  }
   425  
   426  // MachineAddressesResult holds a list of machine addresses or an
   427  // error.
   428  type MachineAddressesResult struct {
   429  	Error     *Error    `json:"error,omitempty"`
   430  	Addresses []Address `json:"addresses"`
   431  }
   432  
   433  // MachineAddressesResults holds the results of calling an API method
   434  // returning a list of addresses per machine.
   435  type MachineAddressesResults struct {
   436  	Results []MachineAddressesResult `json:"results"`
   437  }
   438  
   439  // MachinePortRange holds a single port range open on a machine for
   440  // the given unit and relation tags.
   441  type MachinePortRange struct {
   442  	UnitTag     string    `json:"unit-tag"`
   443  	RelationTag string    `json:"relation-tag"`
   444  	PortRange   PortRange `json:"port-range"`
   445  }
   446  
   447  // MachinePorts holds a machine and subnet tags. It's used when referring to
   448  // opened ports on the machine for a subnet.
   449  type MachinePorts struct {
   450  	MachineTag string `json:"machine-tag"`
   451  	SubnetTag  string `json:"subnet-tag"`
   452  }
   453  
   454  // -----
   455  // API request / response types.
   456  // -----
   457  
   458  // PortsResults holds the bulk operation result of an API call
   459  // that returns a slice of Port.
   460  type PortsResults struct {
   461  	Results []PortsResult `json:"results"`
   462  }
   463  
   464  // PortsResult holds the result of an API call that returns a slice
   465  // of Port or an error.
   466  type PortsResult struct {
   467  	Error *Error `json:"error,omitempty"`
   468  	Ports []Port `json:"ports"`
   469  }
   470  
   471  // UnitNetworkConfigResult holds network configuration for a single unit.
   472  type UnitNetworkConfigResult struct {
   473  	Error *Error `json:"error,omitempty"`
   474  
   475  	// Tagged to Info due to compatibility reasons.
   476  	Config []NetworkConfig `json:"info"`
   477  }
   478  
   479  // UnitNetworkConfigResults holds network configuration for multiple units.
   480  type UnitNetworkConfigResults struct {
   481  	Results []UnitNetworkConfigResult `json:"results"`
   482  }
   483  
   484  // MachineNetworkConfigResult holds network configuration for a single machine.
   485  type MachineNetworkConfigResult struct {
   486  	Error *Error `json:"error,omitempty"`
   487  
   488  	// Tagged to Info due to compatibility reasons.
   489  	Config []NetworkConfig `json:"info"`
   490  }
   491  
   492  // MachineNetworkConfigResults holds network configuration for multiple machines.
   493  type MachineNetworkConfigResults struct {
   494  	Results []MachineNetworkConfigResult `json:"results"`
   495  }
   496  
   497  // HostNetworkChange holds the information about how a host machine should be
   498  // modified to prepare for a container.
   499  type HostNetworkChange struct {
   500  	Error *Error `json:"error,omitempty"`
   501  
   502  	// NewBridges lists the bridges that need to be created and what host
   503  	// device they should be connected to.
   504  	NewBridges []DeviceBridgeInfo `json:"new-bridges"`
   505  
   506  	// ReconfigureDelay is the duration in seconds to sleep before
   507  	// raising the bridged interface
   508  	ReconfigureDelay int `json:"reconfigure-delay"`
   509  }
   510  
   511  // HostNetworkChangeResults holds the network changes that are necessary for multiple containers to be created.
   512  type HostNetworkChangeResults struct {
   513  	Results []HostNetworkChange `json:"results"`
   514  }
   515  
   516  // MachinePortsParams holds the arguments for making a
   517  // FirewallerAPIV1.GetMachinePorts() API call.
   518  type MachinePortsParams struct {
   519  	Params []MachinePorts `json:"params"`
   520  }
   521  
   522  // MachinePortsResult holds a single result of the
   523  // FirewallerAPIV1.GetMachinePorts() and UniterAPI.AllMachinePorts()
   524  // API calls.
   525  type MachinePortsResult struct {
   526  	Error *Error             `json:"error,omitempty"`
   527  	Ports []MachinePortRange `json:"ports"`
   528  }
   529  
   530  // MachinePortsResults holds all the results of the
   531  // FirewallerAPIV1.GetMachinePorts() and UniterAPI.AllMachinePorts()
   532  // API calls.
   533  type MachinePortsResults struct {
   534  	Results []MachinePortsResult `json:"results"`
   535  }
   536  
   537  // APIHostPortsResult holds the result of an APIHostPorts
   538  // call. Each element in the top level slice holds
   539  // the addresses for one API server.
   540  type APIHostPortsResult struct {
   541  	Servers [][]HostPort `json:"servers"`
   542  }
   543  
   544  // NetworkHostsPorts is a convenience helper to return the contained
   545  // result servers as network type.
   546  func (r APIHostPortsResult) NetworkHostsPorts() [][]network.HostPort {
   547  	return NetworkHostsPorts(r.Servers)
   548  }
   549  
   550  // ZoneResult holds the result of an API call that returns an
   551  // availability zone name and whether it's available for use.
   552  type ZoneResult struct {
   553  	Error     *Error `json:"error,omitempty"`
   554  	Name      string `json:"name"`
   555  	Available bool   `json:"available"`
   556  }
   557  
   558  // ZoneResults holds multiple ZoneResult results
   559  type ZoneResults struct {
   560  	Results []ZoneResult `json:"results"`
   561  }
   562  
   563  // SpaceResult holds a single space tag or an error.
   564  type SpaceResult struct {
   565  	Error *Error `json:"error,omitempty"`
   566  	Tag   string `json:"tag"`
   567  }
   568  
   569  // SpaceResults holds the bulk operation result of an API call
   570  // that returns space tags or an errors.
   571  type SpaceResults struct {
   572  	Results []SpaceResult `json:"results"`
   573  }
   574  
   575  // ListSubnetsResults holds the result of a ListSubnets API call.
   576  type ListSubnetsResults struct {
   577  	Results []Subnet `json:"results"`
   578  }
   579  
   580  // SubnetsFilters holds an optional SpaceTag and Zone for filtering
   581  // the subnets returned by a ListSubnets call.
   582  type SubnetsFilters struct {
   583  	SpaceTag string `json:"space-tag,omitempty"`
   584  	Zone     string `json:"zone,omitempty"`
   585  }
   586  
   587  // AddSubnetsParams holds the arguments of AddSubnets API call.
   588  type AddSubnetsParams struct {
   589  	Subnets []AddSubnetParams `json:"subnets"`
   590  }
   591  
   592  // AddSubnetParams holds a subnet and space tags, subnet provider ID,
   593  // and a list of zones to associate the subnet to. Either SubnetTag or
   594  // SubnetProviderId must be set, but not both. Zones can be empty if
   595  // they can be discovered
   596  type AddSubnetParams struct {
   597  	SubnetTag         string   `json:"subnet-tag,omitempty"`
   598  	SubnetProviderId  string   `json:"subnet-provider-id,omitempty"`
   599  	ProviderNetworkId string   `json:"provider-network-id,omitempty"`
   600  	SpaceTag          string   `json:"space-tag"`
   601  	VLANTag           int      `json:"vlan-tag,omitempty"`
   602  	Zones             []string `json:"zones,omitempty"`
   603  }
   604  
   605  // CreateSubnetsParams holds the arguments of CreateSubnets API call.
   606  type CreateSubnetsParams struct {
   607  	Subnets []CreateSubnetParams `json:"subnets"`
   608  }
   609  
   610  // CreateSubnetParams holds a subnet and space tags, vlan tag,
   611  // and a list of zones to associate the subnet to.
   612  type CreateSubnetParams struct {
   613  	SubnetTag string   `json:"subnet-tag,omitempty"`
   614  	SpaceTag  string   `json:"space-tag"`
   615  	Zones     []string `json:"zones,omitempty"`
   616  	VLANTag   int      `json:"vlan-tag,omitempty"`
   617  	IsPublic  bool     `json:"is-public"`
   618  }
   619  
   620  // CreateSpacesParams olds the arguments of the AddSpaces API call.
   621  type CreateSpacesParams struct {
   622  	Spaces []CreateSpaceParams `json:"spaces"`
   623  }
   624  
   625  // CreateSpaceParams holds the space tag and at least one subnet
   626  // tag required to create a new space.
   627  type CreateSpaceParams struct {
   628  	SubnetTags []string `json:"subnet-tags"`
   629  	SpaceTag   string   `json:"space-tag"`
   630  	Public     bool     `json:"public"`
   631  	ProviderId string   `json:"provider-id,omitempty"`
   632  }
   633  
   634  // ListSpacesResults holds the list of all available spaces.
   635  type ListSpacesResults struct {
   636  	Results []Space `json:"results"`
   637  }
   638  
   639  // Space holds the information about a single space and its associated subnets.
   640  type Space struct {
   641  	Name    string   `json:"name"`
   642  	Subnets []Subnet `json:"subnets"`
   643  	Error   *Error   `json:"error,omitempty"`
   644  }
   645  
   646  // ProviderSpace holds the information about a single space and its associated subnets.
   647  type ProviderSpace struct {
   648  	Name       string   `json:"name"`
   649  	ProviderId string   `json:"provider-id"`
   650  	Subnets    []Subnet `json:"subnets"`
   651  	Error      *Error   `json:"error,omitempty"`
   652  }
   653  
   654  type ProxyConfig struct {
   655  	HTTP    string `json:"http"`
   656  	HTTPS   string `json:"https"`
   657  	FTP     string `json:"ftp"`
   658  	NoProxy string `json:"no-proxy"`
   659  }
   660  
   661  // ProxyConfigResult contains information needed to configure a clients proxy settings
   662  type ProxyConfigResult struct {
   663  	LegacyProxySettings      ProxyConfig `json:"legacy-proxy-settings"`
   664  	JujuProxySettings        ProxyConfig `json:"juju-proxy-settings"`
   665  	APTProxySettings         ProxyConfig `json:"apt-proxy-settings,omitempty"`
   666  	SnapProxySettings        ProxyConfig `json:"snap-proxy-settings,omitempty"`
   667  	SnapStoreProxyId         string      `json:"snap-store-id,omitempty"`
   668  	SnapStoreProxyAssertions string      `json:"snap-store-assertions,omitempty"`
   669  	Error                    *Error      `json:"error,omitempty"`
   670  }
   671  
   672  // ProxyConfigResults contains information needed to configure multiple clients proxy settings
   673  type ProxyConfigResults struct {
   674  	Results []ProxyConfigResult `json:"results"`
   675  }
   676  
   677  // ProxyConfigResultV1 contains information needed to configure a clients proxy settings.
   678  // Result for facade v1 call.
   679  type ProxyConfigResultV1 struct {
   680  	ProxySettings    ProxyConfig `json:"proxy-settings"`
   681  	APTProxySettings ProxyConfig `json:"apt-proxy-settings"`
   682  	Error            *Error      `json:"error,omitempty"`
   683  }
   684  
   685  // ProxyConfigResultsV1 contains information needed to configure multiple clients proxy settings.
   686  // Result for facade v1 call.
   687  type ProxyConfigResultsV1 struct {
   688  	Results []ProxyConfigResultV1 `json:"results"`
   689  }
   690  
   691  // InterfaceAddress represents a single address attached to the interface.
   692  type InterfaceAddress struct {
   693  	Hostname string `json:"hostname"`
   694  	Address  string `json:"value"`
   695  	CIDR     string `json:"cidr"`
   696  }
   697  
   698  // NetworkInfo describes one interface with IP addresses.
   699  type NetworkInfo struct {
   700  	// MACAddress is the network interface's hardware MAC address
   701  	// (e.g. "aa:bb:cc:dd:ee:ff").
   702  	MACAddress string `json:"mac-address"`
   703  
   704  	// InterfaceName is the raw OS-specific network device name (e.g.
   705  	// "eth1", even for a VLAN eth1.42 virtual interface).
   706  	InterfaceName string `json:"interface-name"`
   707  
   708  	// Addresses contains a list of addresses configured on the interface.
   709  	Addresses []InterfaceAddress `json:"addresses"`
   710  }
   711  
   712  // NetworkInfoResult Adds egress and ingress subnets and changes the serialized
   713  // `Info` key name in the yaml/json API protocol.
   714  type NetworkInfoResult struct {
   715  	Error            *Error        `json:"error,omitempty" yaml:"error,omitempty"`
   716  	Info             []NetworkInfo `json:"bind-addresses,omitempty" yaml:"bind-addresses,omitempty"`
   717  	EgressSubnets    []string      `json:"egress-subnets,omitempty" yaml:"egress-subnets,omitempty"`
   718  	IngressAddresses []string      `json:"ingress-addresses,omitempty" yaml:"ingress-addresses,omitempty"`
   719  }
   720  
   721  // NetworkInfoResults holds a mapping from binding name to NetworkInfoResult.
   722  type NetworkInfoResults struct {
   723  	Results map[string]NetworkInfoResult `json:"results"`
   724  }
   725  
   726  // NetworkInfoResultV6 holds either and error or a list of NetworkInfos for given binding.
   727  type NetworkInfoResultV6 struct {
   728  	Error *Error        `json:"error,omitempty" yaml:"error,omitempty"`
   729  	Info  []NetworkInfo `json:"network-info" yaml:"info"`
   730  }
   731  
   732  // NetworkInfoResults holds a mapping from binding name to NetworkInfoResultV6.
   733  type NetworkInfoResultsV6 struct {
   734  	Results map[string]NetworkInfoResultV6 `json:"results"`
   735  }
   736  
   737  // NetworkInfoParams holds a name of the unit and list of bindings for which we want to get NetworkInfos.
   738  type NetworkInfoParams struct {
   739  	Unit       string   `json:"unit"`
   740  	RelationId *int     `json:"relation-id,omitempty"`
   741  	Bindings   []string `json:"bindings"`
   742  }
   743  
   744  // FanConfigEntry holds configuration for a single fan.
   745  type FanConfigEntry struct {
   746  	Underlay string `json:"underlay"`
   747  	Overlay  string `json:"overlay"`
   748  }
   749  
   750  // FanConfigResult holds configuration for all fans in a model
   751  type FanConfigResult struct {
   752  	Fans []FanConfigEntry `json:"fans"`
   753  }