forked from projectcalico/libcalico-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
112 lines (97 loc) · 4.11 KB
/
doc.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (c) 2016 Tigera, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Package client implements the northbound client used to manage Calico configuration.
This client is the main entry point for applications that are managing or querying
Calico configuration.
This client provides a typed interface for managing different resource types. The
definitions for each resource type are defined in the following package:
github.com/projectcalico/libcalico-go/lib/api
The client has a number of methods that return interfaces for managing:
- Policy resources
- IP Pool resources
- Host endpoint resources
- Workload resources
- Profile resources
- IP Address Management
See interface definitions for details about the set of management commands for each
resource type.
The resource management interfaces have a common set of commands to create, delete,
update and retrieve resource instances. For example, an application using this
client to manage host endpoint resources would create an instance of this client, create a
new HostEndpoints interface and call the appropriate methods on that interface. For example:
// ClientConfig defaults to access an etcd backend datastore at
// localhost:2379. For alternative access details, set the appropriate
// fields in the ClientConfig structure.
config := api.ClientConfig{}
client := New(&config)
// Obtain the interface for managing host endpoint resources.
hostendpoints := client.HostEndpoints()
// Create a new host endpoint. All Create() methods return an error of type
// common.ErrorResourceAlreadyExists if the resource specified by its
// unique identifiers already exists.
hostEndpoint, err := hostEndpoints.Create(&api.HostEndpoint{
Metadata: api.HostEndpointMetadata{
Name: "endpoint1",
Hostname: "hostname1",
},
Spec: api.HostEndpointSpec{
InterfaceName: "eth0"
},
}
// Update an existing host endpoint. All Update() methods return an error of type
// common.ErrorResourceDoesNotExist if the resource specified by its
// unique identifiers does not exist.
hostEndpoint, err = hostEndpoints.Update(&api.HostEndpoint{
Metadata: api.HostEndpointMetadata{
Name: "endpoint1",
Hostname: "hostname1",
},
Spec: api.HostEndpointSpec{
InterfaceName: "eth0",
Profiles: []string{"profile1"},
},
}
// Apply (update or create) a hostEndpoint. All Apply() methods will update a resource
// if it already exists, and will create a new resource if it does not.
hostEndpoint, err = hostEndpoints.Apply(&api.HostEndpoint{
Metadata: api.HostEndpointMetadata{
Name: "endpoint1",
Hostname: "hostname1",
},
Spec: api.HostEndpointSpec{
InterfaceName: "eth1",
Profiles: []string{"profile1"},
},
}
// Delete a hostEndpoint. All Delete() methods return an error of type
// common.ErrorResourceDoesNotExist if the resource specified by its
// unique identifiers does not exist.
hostEndpoint, err = hostEndpoints.Delete(api.HostEndpointMetadata{
Name: "endpoint1",
Hostname: "hostname1",
})
// Get a hostEndpoint. All Get() methods return an error of type
// common.ErrorResourceDoesNotExist if the resource specified by its
// unique identifiers does not exist.
hostEndpoint, err = hostEndpoints.Get(api.HostEndpointMetadata{
Name: "endpoint1",
Hostname: "hostname1",
})
// List all hostEndpoints. All List() methods take a (sub-)set of the resource
// identifiers and return the corresponding list resource type that has an
// Items field containing a list of resources that match the supplied
// identifiers.
hostEndpointList, err := hostEndpoints.List(api.HostEndpointMetadata{})
*/
package client