-
Notifications
You must be signed in to change notification settings - Fork 4
/
containerworkloadprofiles.go
51 lines (47 loc) · 2.84 KB
/
containerworkloadprofiles.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
package illumioapi
type ContainerWorkloadProfileAssignLabel struct {
Href string `json:"href,omitempty"`
}
type ContainerWorkloadProfileLabel struct {
Key string `json:"key,omitempty"`
Assignment ContainerWorkloadProfileLabelAssignment `json:"assignment,omitempty"`
}
type ContainerWorkloadProfileLabelAssignment struct {
Href string `json:"href,omitempty"`
Value string `json:"value,omitempty"`
}
// ContainerWorkloadProfile represents a container workload profile in the Illumio PCE
type ContainerWorkloadProfile struct {
Href string `json:"href,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Description string `json:"description,omitempty"`
EnforcementMode string `json:"enforcement_mode,omitempty"`
VisibilityLevel string `json:"visibility_level,omitempty"`
Managed *bool `json:"managed,omitempty"`
Linked *bool `json:"linked,omitempty"`
AssignLabels []ContainerWorkloadProfileAssignLabel `json:"assign_labels,omitempty"`
Labels []ContainerWorkloadProfileLabel `json:"labels,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
CreatedBy *CreatedBy `json:"created_by,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
UpdatedBy *UpdatedBy `json:"updated_by,omitempty"`
}
// GetContainerWkldProfiles returns a slice of container workload profiles from the PCE.
// queryParameters can be used for filtering in the form of ["parameter"]="value".
// The first API call to the PCE does not use the async option.
// If the slice length is >=500, it re-runs with async.
func (p *PCE) GetContainerWkldProfiles(queryParameters map[string]string, containerClusterID string) (containerWkldProfiles []ContainerWorkloadProfile, api APIResponse, err error) {
api, err = p.GetCollection("container_clusters/"+containerClusterID+"/container_workload_profiles", false, queryParameters, &containerWkldProfiles)
if len(containerWkldProfiles) >= 500 {
containerWkldProfiles = nil
api, err = p.GetCollection("container_clusters/"+containerClusterID+"/container_workload_profiles", true, queryParameters, &containerWkldProfiles)
}
p.ContainerWorkloadProfilesSlice = containerWkldProfiles
p.ContainerWorkloadProfiles = make(map[string]ContainerWorkloadProfile)
for _, c := range containerWkldProfiles {
p.ContainerWorkloadProfiles[c.Href] = c
p.ContainerWorkloadProfiles[c.Name] = c
}
return containerWkldProfiles, api, err
}