| identity "github.com/rackspace/gophercloud/openstack/identity/v2" |
| "github.com/rackspace/gophercloud/openstack/utils" |
| "github.com/rackspace/gophercloud/rackspace/monitoring" |
| "github.com/rackspace/gophercloud/rackspace/monitoring/notificationPlans" |
| func TestRBACPermissions(t *testing.T) { |
| ao, err := utils.AuthOptions() |
| r, err := identity.Authenticate(ao) |
| // Find the cloud monitoring API |
| sc, err := identity.GetServiceCatalog(r) |
| ces, err := sc.CatalogEntries() |
| monUrl, err := findMonitoringEndpoint(ces) |
| // Build ourselves an interface to cloud monitoring! |
| np := notificationPlans.NewClient(monitoring.Options{ |
| // Try to delete a bogus notification plan |
| dr, err := np.Delete("ajkhdlkajhdflkajshdf") |
| func findMonitoringEndpoint(ces []identity.CatalogEntry) (string, error) { |
| if ce.Type == "rax:monitor" { |
| return ce.Endpoints[0].PublicURL, nil |
| return "", fmt.Errorf("No monitoring API in the service catalog") |