forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clusternetwork.go
50 lines (42 loc) · 1.74 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
43
44
45
46
47
48
49
50
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)
Update(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
}
// Update updates the ClusterNetwork on the server. Returns the server's representation of the ClusterNetwork and error if one occurs.
func (c *clusterNetwork) Update(cn *sdnapi.ClusterNetwork) (result *sdnapi.ClusterNetwork, err error) {
result = &sdnapi.ClusterNetwork{}
err = c.r.Put().Resource("clusterNetworks").Name(cn.Name).Body(cn).Do().Into(result)
return
}