forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clusternetwork.go
42 lines (35 loc) · 1.31 KB
/
clusternetwork.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package client
import (
sdnapi "github.com/openshift/origin/pkg/sdn/api"
)
// ClusterNetworkingInterface has methods to work with ClusterNetwork resources
type ClusterNetworkingInterface interface {
ClusterNetwork() ClusterNetworkInterface
}
// ClusterNetworkInterface exposes methods on clusterNetwork resources.
type ClusterNetworkInterface interface {
Get(name string) (*sdnapi.ClusterNetwork, error)
Create(sub *sdnapi.ClusterNetwork) (*sdnapi.ClusterNetwork, error)
}
// clusterNetwork implements ClusterNetworkInterface interface
type clusterNetwork struct {
r *Client
}
// newClusterNetwork returns a clusterNetwork
func newClusterNetwork(c *Client) *clusterNetwork {
return &clusterNetwork{
r: c,
}
}
// Get returns information about a particular network
func (c *clusterNetwork) Get(networkName string) (result *sdnapi.ClusterNetwork, err error) {
result = &sdnapi.ClusterNetwork{}
err = c.r.Get().Resource("clusterNetworks").Name(networkName).Do().Into(result)
return
}
// Create creates a new ClusterNetwork. Returns the server's representation of ClusterNetwork and error if one occurs.
func (c *clusterNetwork) Create(cn *sdnapi.ClusterNetwork) (result *sdnapi.ClusterNetwork, err error) {
result = &sdnapi.ClusterNetwork{}
err = c.r.Post().Resource("clusterNetworks").Body(cn).Do().Into(result)
return
}