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 Client
- func (c *Client) DeleteNetworkContainer(ctx context.Context, dcr DeleteContainerRequest) 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
- type Config
- type ContentError
- type DeleteContainerRequest
- type Error
- type GetNetworkConfigRequest
- type JoinNetworkRequest
- type Policy
- type PutNetworkContainerRequest
- type Request
- type Subnet
- type Tag
- type VirtualNetwork
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an agent for exchanging information with NMAgent.
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) 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
// 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 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
}
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) 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 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 `validate:"presence" 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 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 {
ID string `json:"networkContainerID"` // the id of the network container
VNetID string `json:"virtualNetworkID"` // the id of the customer's vnet
// Version is the new network container version
Version uint64 `json:"version"`
// 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 `json:"subnetName"`
// IPv4 addresses in the customer virtual network that will be assigned to
// the interface.
IPv4Addrs []string `json:"ipV4Addresses"`
Policies []Policy `json:"policies"` // 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 `json:"vlanId"`
GREKey uint16 `json:"greKey"`
// AuthenticationToken is the base64 security token for the subnet containing
// the Network Container addresses
AuthenticationToken string `json:"-"`
// PrimaryAddress is the primary customer address of the interface in the
// management VNet
PrimaryAddress string `json:"-"`
}
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) 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) 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.