Go package to interact with the Illumio API.
The new default branch is v2. The v1 branch will be minimally maintained. Version 1 was built as needed and as it evolved there were many things that would have bee done differently from the start. Version 2 looks to address a lot of these. See below for a non-exhaustive list of the major changes:
- Version 2 aims for better consistency for when pointers are used in structs. Pointers are used for custom types, slices, and booleans as well as any integer or string that could need to be cleared in the PCE. For example, an
hrefnever can be cleared in the PCE so it is astring. Adescriptioncould be cleared (e.g., send aPUTrequest to remove a description). In that case it's a*stringso you can send a blank string withomitemptyto clear it or anilvalue to have it omitted. - Version 2 has some helper functions to deal with all of the pointers in the data structure.
PtrToValcan be used on any pointer to return its value or blank value if it'snil. The goal is to reduce the checking ofnilbefore doing a comparison or using a value where appropriate. - Version 2 does not return slices for getting policy objects. For example
pce.GetWkldswill return just theAPItype and anerr. The policy objects are populated into thepceslices and maps.
All interactions with the PCE are done via methods on the pce type. For example, the code below prints all hostnames:
// Create PCE
pce := illumioapi.PCE{
FQDN: "bp-lab.poc.segmentationpov.com",
Port: 8443,
DisableTLSChecking: true}
// Login and ignore error checking for example
pce.Login("[email protected]", "Password123")
// Get all workloads
api, err := pce.GetWklds(nil)
fmt.Println(api.StatusCode)
if err != nil {
log.Fatal(err)
}
// Iterate through workloads and print hostname
for _, w := range pce.WorkloadsSlice {
fmt.Println(w.Hostname)
}