Documentation ¶
Overview ¶
package nmagent contains types and functions necessary for interacting with the Network Manager Agent (NMAgent).
Index ¶
- func NewContentError(contentType string, in io.Reader, limit int64) error
- type AzResponse
- type Client
- func (c *Client) DeleteNetwork(ctx context.Context, dnr DeleteNetworkRequest) error
- func (c *Client) DeleteNetworkContainer(ctx context.Context, dcr DeleteContainerRequest) error
- func (c *Client) GetHomeAz(ctx context.Context) (AzResponse, error)
- func (c *Client) GetNCVersion(ctx context.Context, ncvr NCVersionRequest) (NCVersion, error)
- func (c *Client) GetNCVersionList(ctx context.Context) (NCVersionList, error)
- func (c *Client) GetNetworkConfiguration(ctx context.Context, gncr GetNetworkConfigRequest) (VirtualNetwork, error)
- func (c *Client) JoinNetwork(ctx context.Context, jnr JoinNetworkRequest) error
- func (c *Client) PutNetworkContainer(ctx context.Context, pncr *PutNetworkContainerRequest) error
- func (c *Client) SupportedAPIs(ctx context.Context) ([]string, error)
- type Config
- type ContentError
- type DeleteContainerRequest
- type DeleteNetworkRequest
- type Error
- type GetHomeAzRequest
- type GetNetworkConfigRequest
- type JoinNetworkRequest
- type NCVersion
- type NCVersionList
- type NCVersionListRequest
- type NCVersionRequest
- type Policy
- type PutNetworkContainerRequest
- func (p *PutNetworkContainerRequest) Body() (io.Reader, error)
- func (p *PutNetworkContainerRequest) MarshalJSON() ([]byte, error)
- func (p *PutNetworkContainerRequest) Method() string
- func (p *PutNetworkContainerRequest) Path() string
- func (p *PutNetworkContainerRequest) UnmarshalJSON(in []byte) error
- func (p *PutNetworkContainerRequest) Validate() error
- type Request
- type Subnet
- type SupportedAPIsRequest
- type SupportedAPIsResponseXML
- type Tag
- type VirtualNetwork
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AzResponse ¶
type AzResponse struct {
HomeAz uint `json:"homeAz"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an agent for exchanging information with NMAgent.
func (*Client) DeleteNetwork ¶
func (c *Client) DeleteNetwork(ctx context.Context, dnr DeleteNetworkRequest) error
DeleteNetwork deletes a customer network and it's associated subnets.
func (*Client) DeleteNetworkContainer ¶
func (c *Client) DeleteNetworkContainer(ctx context.Context, dcr DeleteContainerRequest) error
DeleteNetworkContainer removes a Network Container, its associated IP addresses, and network policies from an interface.
func (*Client) GetHomeAz ¶
func (c *Client) GetHomeAz(ctx context.Context) (AzResponse, error)
GetHomeAz gets node's home az from nmagent
func (*Client) GetNCVersion ¶
GetNetworkContainerVersion gets the current goal state version of a Network Container. This method can be used to detect changes in a Network Container's state that would indicate that it requires re-programming. The request must originate from a VM network interface that has a Swift Provisioning OwningServiceInstanceId property. The authentication token must match the token on the subnet containing the Network Container address.
func (*Client) GetNCVersionList ¶
func (c *Client) GetNCVersionList(ctx context.Context) (NCVersionList, error)
func (*Client) GetNetworkConfiguration ¶
func (c *Client) GetNetworkConfiguration(ctx context.Context, gncr GetNetworkConfigRequest) (VirtualNetwork, error)
GetNetworkConfiguration retrieves the configuration of a customer's virtual network. Only subnets which have been delegated will be returned.
func (*Client) JoinNetwork ¶
func (c *Client) JoinNetwork(ctx context.Context, jnr JoinNetworkRequest) error
JoinNetwork joins a node to a customer's virtual network.
func (*Client) PutNetworkContainer ¶
func (c *Client) PutNetworkContainer(ctx context.Context, pncr *PutNetworkContainerRequest) error
PutNetworkContainer applies a Network Container goal state and publishes it to PubSub.
type Config ¶
type Config struct { ///////////////////// // Required Config // ///////////////////// Host string // the host the client will connect to Port uint16 // the port the client will connect to ///////////////////// // Optional Config // ///////////////////// UseTLS bool // forces all connections to use TLS }
Config is a configuration for an NMAgent Client.
type ContentError ¶
type ContentError struct { Type string // the mime type of the content received Body []byte // the received body }
ContentError is encountered when an unexpected content type is obtained from NMAgent.
func (ContentError) Error ¶
func (c ContentError) Error() string
type DeleteContainerRequest ¶
type DeleteContainerRequest struct { NCID string `json:"-"` // the Network Container ID AzID uint `json:"azID"` // home AZ of the Network Container AZREnabled bool `json:"azrEnabled"` // whether AZR is enabled or not // PrimaryAddress is the primary customer address of the interface in the // management VNET PrimaryAddress string `json:"-"` AuthenticationToken string `json:"-"` }
DeleteContainerRequest represents all information necessary to request that NMAgent delete a particular network container
func (DeleteContainerRequest) Body ¶
func (d DeleteContainerRequest) Body() (io.Reader, error)
Body returns nothing, because DeleteContainerRequests have no HTTP body
func (DeleteContainerRequest) Method ¶
func (d DeleteContainerRequest) Method() string
Method returns the HTTP method required to submit a DeleteContainerRequest
func (DeleteContainerRequest) Path ¶
func (d DeleteContainerRequest) Path() string
Path returns the path for submitting a DeleteContainerRequest with parameters interpolated correctly
func (DeleteContainerRequest) Validate ¶
func (d DeleteContainerRequest) Validate() error
Validate ensures that the DeleteContainerRequest has the correct information to submit the request
type DeleteNetworkRequest ¶
type DeleteNetworkRequest struct {
NetworkID string `json:"-"` // the customer's VNet ID
}
DeleteNetworkRequest represents all information necessary to request that NMAgent delete a particular network
func (DeleteNetworkRequest) Body ¶
func (d DeleteNetworkRequest) Body() (io.Reader, error)
Body returns nothing, because DeleteNetworkRequest has no request body
func (DeleteNetworkRequest) Method ¶
func (d DeleteNetworkRequest) Method() string
Method returns the HTTP request method to submit a DeleteNetworkRequest
func (DeleteNetworkRequest) Path ¶
func (d DeleteNetworkRequest) Path() string
Path constructs a URL path for invoking a DeleteNetworkRequest using the provided parameters
func (DeleteNetworkRequest) Validate ¶
func (d DeleteNetworkRequest) Validate() error
Validate ensures that the provided parameters of the request are valid
type Error ¶
type Error struct { Code int // the HTTP status code received Source string // the component responsible for producing the error Body []byte // the body of the error returned Path string // the path of the request that produced the error }
Error is a aberrent condition encountered when interacting with the NMAgent API.
func (Error) Error ¶
Error constructs a string representation of this error in accordance with the error interface.
func (Error) Message ¶
Message interprets the HTTP Status code from NMAgent and returns the corresponding explanation from the documentation.
func (Error) NotFound ¶
NotFound reports whether the error was produced as a result of the resource not existing.
func (Error) StatusCode ¶
StatusCode returns the HTTP status associated with this error.
func (Error) Temporary ¶
Temporary reports whether the error encountered from NMAgent should be considered temporary, and thus retriable.
func (Error) Unauthorized ¶
Unauthorized reports whether the error was produced as a result of submitting the request from an interface without an OwningServiceInstanceId property. In some cases, this can be a transient condition that could be retried.
type GetHomeAzRequest ¶
type GetHomeAzRequest struct{}
func (*GetHomeAzRequest) Body ¶
func (g *GetHomeAzRequest) Body() (io.Reader, error)
Body is a no-op method to satisfy the Request interface while indicating that there is no body for a GetHomeAz Request.
func (*GetHomeAzRequest) Method ¶
func (g *GetHomeAzRequest) Method() string
Method indicates that GetHomeAz requests are GET requests.
func (*GetHomeAzRequest) Path ¶
func (g *GetHomeAzRequest) Path() string
Path returns the necessary URI path for invoking a GetHomeAz request.
func (*GetHomeAzRequest) Validate ¶
func (g *GetHomeAzRequest) Validate() error
Validate is a no-op method because GetHomeAzRequest have no parameters, and therefore can never be invalid.
type GetNetworkConfigRequest ¶
type GetNetworkConfigRequest struct {
VNetID string `json:"-"` // the customer's virtual network ID
}
GetNetworkConfigRequest is a collection of necessary information for submitting a request for a customer's network configuration
func (GetNetworkConfigRequest) Body ¶
func (g GetNetworkConfigRequest) Body() (io.Reader, error)
Body returns nothing because GetNetworkConfigRequest has no HTTP request body
func (GetNetworkConfigRequest) Method ¶
func (g GetNetworkConfigRequest) Method() string
Method returns the HTTP method required to submit a GetNetworkConfigRequest
func (GetNetworkConfigRequest) Path ¶
func (g GetNetworkConfigRequest) Path() string
Path produces a URL path used to submit a request
func (GetNetworkConfigRequest) Validate ¶
func (g GetNetworkConfigRequest) Validate() error
Validate ensures that the request is complete and the parameters are correct
type JoinNetworkRequest ¶
type JoinNetworkRequest struct {
NetworkID string `json:"-"` // the customer's VNet ID
}
func (JoinNetworkRequest) Body ¶
func (j JoinNetworkRequest) Body() (io.Reader, error)
Body returns nothing, because JoinNetworkRequest has no request body
func (JoinNetworkRequest) Method ¶
func (j JoinNetworkRequest) Method() string
Method returns the HTTP request method to submit a JoinNetworkRequest
func (JoinNetworkRequest) Path ¶
func (j JoinNetworkRequest) Path() string
Path constructs a URL path for invoking a JoinNetworkRequest using the provided parameters
func (JoinNetworkRequest) Validate ¶
func (j JoinNetworkRequest) Validate() error
Validate ensures that the provided parameters of the request are valid
type NCVersion ¶
type NCVersion struct { NetworkContainerID string `json:"networkContainerId"` Version string `json:"version"` // the current network container version }
NCVersion is a response produced from requests for a network container's version.
type NCVersionList ¶
type NCVersionList struct {
Containers []NCVersion `json:"networkContainers"`
}
NetworkContainerListResponse is a collection of network container IDs mapped to their current versions.
type NCVersionListRequest ¶
type NCVersionListRequest struct{}
NCVersionListRequest is a collection of parameters necessary to submit a request to receive a list of NCVersions available from the NMAgent instance.
func (NCVersionListRequest) Method ¶
func (NCVersionListRequest) Method() string
Method returns the HTTP method required for the request.
func (NCVersionListRequest) Path ¶
func (NCVersionListRequest) Path() string
Path returns the path required to issue the request.
func (NCVersionListRequest) Validate ¶
func (NCVersionListRequest) Validate() error
Validate performs any necessary validations for the request.
type NCVersionRequest ¶
type NCVersionRequest struct { AuthToken string `json:"-"` NetworkContainerID string `json:"-"` PrimaryAddress string `json:"-"` }
func (NCVersionRequest) Method ¶
func (n NCVersionRequest) Method() string
Method indicates this request is a GET request
func (NCVersionRequest) Path ¶
func (n NCVersionRequest) Path() string
Path returns the URL Path for the request with parameters interpolated as necessary.
func (NCVersionRequest) Validate ¶
func (n NCVersionRequest) Validate() error
Validate ensures the presence of all parameters of the NCVersionRequest, as none are optional.
type Policy ¶
func (Policy) MarshalJSON ¶
MarshalJson encodes policies as a JSON string, separated by a comma. This specific format is requested by the NMAgent documentation
func (*Policy) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON-encoded policy string
type PutNetworkContainerRequest ¶
type PutNetworkContainerRequest struct { // NOTE(traymond): if you are adding a new field to this struct, ensure that it is also added // to the MarshallJSON, UnmarshallJSON and method as well. ID string // the id of the network container VNetID string // the id of the customer's vnet // Version is the new network container version Version uint64 // SubnetName is the name of the delegated subnet. This is used to // authenticate the request. The list of ipv4addresses must be contained in // the subnet's prefix. SubnetName string // IPv4 addresses in the customer virtual network that will be assigned to // the interface. IPv4Addrs []string Policies []Policy // policies applied to the network container // VlanID is used to distinguish Network Containers with duplicate customer // addresses. "0" is considered a default value by the API. VlanID int GREKey uint16 // AuthenticationToken is the base64 security token for the subnet containing // the Network Container addresses AuthenticationToken string // PrimaryAddress is the primary customer address of the interface in the // management VNet PrimaryAddress string // AzID is the home AZ ID of the network container AzID uint // AZREnabled denotes whether AZR is enabled for network container or not AZREnabled bool }
PutNetworkContainerRequest is a collection of parameters necessary to create a new network container
func (*PutNetworkContainerRequest) Body ¶
func (p *PutNetworkContainerRequest) Body() (io.Reader, error)
Body marshals the JSON fields of the request and produces an Reader intended for use with an HTTP request
func (*PutNetworkContainerRequest) MarshalJSON ¶
func (p *PutNetworkContainerRequest) MarshalJSON() ([]byte, error)
func (*PutNetworkContainerRequest) Method ¶
func (p *PutNetworkContainerRequest) Method() string
Method returns the HTTP method for this request type
func (*PutNetworkContainerRequest) Path ¶
func (p *PutNetworkContainerRequest) Path() string
Path returns the URL path necessary to submit this PutNetworkContainerRequest
func (*PutNetworkContainerRequest) UnmarshalJSON ¶
func (p *PutNetworkContainerRequest) UnmarshalJSON(in []byte) error
func (*PutNetworkContainerRequest) Validate ¶
func (p *PutNetworkContainerRequest) Validate() error
Validate ensures that all of the required parameters of the request have been filled out properly prior to submission to NMAgent
type Request ¶
type Request interface { // Validate should ensure that the request is valid to submit Validate() error // Path should produce a URL path, complete with any URL parameters // interpolated Path() string // Body produces the HTTP request body necessary to submit the request Body() (io.Reader, error) // Method returns the HTTP Method to be used for the request. Method() string }
Request represents an abstracted HTTP request, capable of validating itself, producing a valid Path, Body, and its Method.
type SupportedAPIsRequest ¶
type SupportedAPIsRequest struct{}
SupportedAPIsRequest is a collection of parameters necessary to submit a valid request to retrieve the supported APIs from an NMAgent instance.
func (*SupportedAPIsRequest) Body ¶
func (s *SupportedAPIsRequest) Body() (io.Reader, error)
Body is a no-op method to satisfy the Request interface while indicating that there is no body for a SupportedAPIs Request.
func (*SupportedAPIsRequest) Method ¶
func (s *SupportedAPIsRequest) Method() string
Method indicates that SupportedAPIs requests are GET requests.
func (*SupportedAPIsRequest) Path ¶
func (s *SupportedAPIsRequest) Path() string
Path returns the necessary URI path for invoking a supported APIs request.
func (*SupportedAPIsRequest) Validate ¶
func (s *SupportedAPIsRequest) Validate() error
Validate is a no-op method because SupportedAPIsRequests have no parameters, and therefore can never be invalid.
type SupportedAPIsResponseXML ¶
type SupportedAPIsResponseXML struct {
SupportedApis []string `xml:"type"`
}