Documentation ¶
Overview ¶
Package services allows management and retrieval of VPN services in the OpenStack Networking Service.
Example to List Services
listOpts := services.ListOpts{ TenantID: "966b3c7d36a24facaf20b7e458bf2192", } allPages, err := services.List(networkClient, listOpts).AllPages() if err != nil { panic(err) } allPolicies, err := services.ExtractServices(allPages) if err != nil { panic(err) } for _, service := range allServices { fmt.Printf("%+v\n", service) }
Example to Create a Service
createOpts := services.CreateOpts{ Name: "vpnservice1", Description: "A service", RouterID: "2512e759-e8d7-4eea-a0af-4a85927a2e59", AdminStateUp: gophercloud.Enabled, } service, err := services.Create(networkClient, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Service
serviceID := "38aee955-6283-4279-b091-8b9c828000ec" updateOpts := services.UpdateOpts{ Description: "New Description", } service, err := services.Update(networkClient, serviceID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Service
serviceID := "38aee955-6283-4279-b091-8b9c828000ec" err := services.Delete(networkClient, serviceID).ExtractErr() if err != nil { panic(err) }
Example to Show the details of a specific Service by ID
service, err := services.Get(client, "f2b08c1e-aa81-4668-8ae1-1401bcb0576c").Extract() if err != nil { panic(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns a Pager which allows you to iterate over a collection of VPN services. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // TenantID specifies a tenant to own the VPN service. The caller must have // an admin role in order to set this. Otherwise, this field is left unset // and the caller will be the owner. TenantID string `json:"tenant_id,omitempty"` // SubnetID is the ID of the subnet. SubnetID string `json:"subnet_id,omitempty"` // RouterID is the ID of the router. RouterID string `json:"router_id" required:"true"` // Description is the human readable description of the service. Description string `json:"description,omitempty"` // AdminStateUp is the administrative state of the resource, which is up (true) or down (false). AdminStateUp *bool `json:"admin_state_up"` // Name is the human readable name of the service. Name string `json:"name,omitempty"` // The ID of the flavor. FlavorID string `json:"flavor_id,omitempty"` }
CreateOpts contains all the values needed to create a new VPN service
func (CreateOpts) ToServiceCreateMap ¶
func (opts CreateOpts) ToServiceCreateMap() (map[string]interface{}, error)
ToServiceCreateMap casts a CreateOpts struct to a map.
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 Service.
func Create ¶
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create accepts a CreateOpts struct and uses the values to create a new VPN service.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the operation succeeded or failed.
func Delete ¶
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete will permanently delete a particular VPN service based on its unique ID.
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 Service.
func Get ¶
func Get(c *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves a particular VPN service based on its unique ID.
type ListOpts ¶
type ListOpts struct { TenantID string `q:"tenant_id"` Name string `q:"name"` Description string `q:"description"` AdminStateUp *bool `q:"admin_state_up"` Status string `q:"status"` SubnetID string `q:"subnet_id"` RouterID string `q:"router_id"` ProjectID string `q:"project_id"` ExternalV6IP string `q:"external_v6_ip"` ExternalV4IP string `q:"external_v4_ip"` FlavorID string `q:"flavor_id"` }
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 VPN service attributes you want to see returned.
func (ListOpts) ToServiceListQuery ¶
ToServiceListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type Service ¶
type Service struct { // TenantID is the ID of the project. TenantID string `json:"tenant_id"` // ProjectID is the ID of the project. ProjectID string `json:"project_id"` // SubnetID is the ID of the subnet. SubnetID string `json:"subnet_id"` // RouterID is the ID of the router. RouterID string `json:"router_id"` // Description is a human-readable description for the resource. // Default is an empty string Description string `json:"description"` // AdminStateUp is the administrative state of the resource, which is up (true) or down (false). AdminStateUp bool `json:"admin_state_up"` // Name is the human readable name of the service. Name string `json:"name"` // Status indicates whether IPsec VPN service is currently operational. // Values are ACTIVE, DOWN, BUILD, ERROR, PENDING_CREATE, PENDING_UPDATE, or PENDING_DELETE. Status string `json:"status"` // ID is the unique ID of the VPN service. ID string `json:"id"` // ExternalV6IP is the read-only external (public) IPv6 address that is used for the VPN service. ExternalV6IP string `json:"external_v6_ip"` // ExternalV4IP is the read-only external (public) IPv4 address that is used for the VPN service. ExternalV4IP string `json:"external_v4_ip"` // FlavorID is the ID of the flavor. FlavorID string `json:"flavor_id"` }
Service is a VPN Service
func ExtractServices ¶
func ExtractServices(r pagination.Page) ([]Service, error)
ExtractServices accepts a Page struct, specifically a Service struct, and extracts the elements into a slice of Service structs. In other words, a generic collection is mapped into a relevant slice.
type ServicePage ¶
type ServicePage struct {
pagination.LinkedPageBase
}
ServicePage is the page returned by a pager when traversing over a collection of VPN services.
func (ServicePage) IsEmpty ¶
func (r ServicePage) IsEmpty() (bool, error)
IsEmpty checks whether a ServicePage struct is empty.
func (ServicePage) NextPageURL ¶
func (r ServicePage) NextPageURL() (string, error)
NextPageURL is invoked when a paginated collection of VPN services has 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.
type UpdateOpts ¶
type UpdateOpts struct { // Name is the human readable name of the service. Name *string `json:"name,omitempty"` // Description is the human readable description of the service. Description *string `json:"description,omitempty"` // AdminStateUp is the administrative state of the resource, which is up (true) or down (false). AdminStateUp *bool `json:"admin_state_up,omitempty"` }
UpdateOpts contains the values used when updating a VPN service
func (UpdateOpts) ToServiceUpdateMap ¶
func (opts UpdateOpts) ToServiceUpdateMap() (map[string]interface{}, error)
ToServiceUpdateMap casts aa UodateOpts struct to a map.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a service.
func Update ¶
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update allows VPN services to be updated.