Documentation ¶
Overview ¶
Package ports contains functionality for working with FIC Port resources.
Example to List Ports
listOpts := ports.ListOpts{} allPages, err := ports.List(client, listOpts).AllPages() if err != nil { panic(err) } allPorts, err := ports.ExtractPorts(allPages) if err != nil { panic(err) } for _, port := range allPorts { fmt.Printf("%+v", port) }
Example to Create a Port
createOpts := ports.CreateOpts{ Name: "YourPortName", SwitchName: "SwitchName", NumberOfVLANs: 32, PortType: "1G", } port, err := ports.Create(client, createOpts).Extract() if err != nil { panic(err) }
Example to Delete a Port
portID := "484cda0e-106f-4f4b-bb3f-d413710bbe78" err := ports.Delete(client, portID).ExtractErr() if err != nil { panic(err) }
Example to Activate a Port
port, err := ports.Activate(client, map[string]interface{}{}).Extract() if err != nil { panic(err) }
Index ¶
- func ExtractPortsInto(r pagination.Page, v interface{}) error
- func List(c *fic.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type ActivateResult
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type Port
- type PortPage
- type VLAN
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractPortsInto ¶
func ExtractPortsInto(r pagination.Page, v interface{}) error
ExtractPortsInto interprets the results of a single page from a List() call, producing a slice of Port entities.
func List ¶
func List(c *fic.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns a Pager which allows you to iterate over a collection of ports. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Types ¶
type ActivateResult ¶
type ActivateResult struct {
// contains filtered or unexported fields
}
ActivateResult represents the result of a activate operation. Call its Extract method to interpret it as a Port.
func Activate ¶
func Activate(c *fic.ServiceClient, portID string) (r ActivateResult)
func (ActivateResult) Extract ¶
Extract is a function that accepts a result and extracts a port resource.
func (ActivateResult) ExtractInto ¶
func (r ActivateResult) ExtractInto(v interface{}) error
Extract interprets any commonResult as a Port, if possible.
type CreateOpts ¶
type CreateOpts struct { Name string `json:"name" required:"true"` SwitchName string `json:"switchName" required:"true"` NumberOfVLANs int `json:"numOfVlans,omitempty"` VLANRanges []string `json:"vlanRanges,omitempty"` PortType string `json:"portType" required:"true"` }
CreateOpts represents options used to create a port.
func (CreateOpts) ToPortCreateMap ¶
func (opts CreateOpts) ToPortCreateMap() (map[string]interface{}, error)
ToPortCreateMap builds a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Port.
func Create ¶
func Create(c *fic.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create accepts a CreateOpts struct and creates a port using the values provided. This operation does not actually require a request body, i.e. the CreateOpts struct argument can be empty.
func (CreateResult) Extract ¶
Extract is a function that accepts a result and extracts a port resource.
func (CreateResult) ExtractInto ¶
func (r CreateResult) ExtractInto(v interface{}) error
Extract interprets any commonResult as a Port, if possible.
type DeleteResult ¶
type DeleteResult struct {
fic.ErrResult
}
DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.
func Delete ¶
func Delete(c *fic.ServiceClient, portID string) (r DeleteResult)
Delete accepts a unique ID and deletes the port associated with it.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult represents the result of a get operation. Call its Extract method to interpret it as a Port.
func (GetResult) Extract ¶
Extract is a function that accepts a result and extracts a port resource.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(v interface{}) error
Extract interprets any commonResult as a Port, if possible.
type ListOpts ¶
type ListOpts struct { }
ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the port attributes you want to see returned.
func (ListOpts) ToPortListQuery ¶
ToPortListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type Port ¶
type Port struct { ID string `json:"id"` Name string `json:"name"` OperationStatus string `json:"operationStatus"` IsActivated bool `json:"isActivated"` VLANRanges []string `json:"vlanRanges"` TenantID string `json:"tenantId"` SwitchName string `json:"switchName"` PortType string `json:"portType"` Location string `json:"location"` Area string `json:"area"` VLANs []VLAN `json:"vlans"` OperationID string `json:"operationId"` }
Port represents port resource.
func ExtractPorts ¶
func ExtractPorts(r pagination.Page) ([]Port, error)
ExtractPorts accepts a Page struct, specifically a PortPage struct, and extracts the elements into a slice of Port structs. In other words, a generic collection is mapped into a relevant slice.
type PortPage ¶
type PortPage struct {
pagination.LinkedPageBase
}
PortPage is the page returned by a pager when traversing over a collection of ports.
func (PortPage) NextPageURL ¶
NextPageURL is invoked when a paginated collection of ports have reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.