// FlavorsDetail will issue a GET request to retrieve all flavors detail. func (computeService Service) FlavorsDetail() ([]FlavorDetail, error) { result := []FlavorDetail{} marker := "" more := true var err error for more { container := FlavorsDetailContainer{} url, err := computeService.buildPaginatedQueryURL(QueryParameters{Limit: defaultLimit, Marker: marker}, "/flavors/detail") if err != nil { return container.FlavorsDetail, err } err = misc.GetJSON(url.String(), computeService.authenticator, &container) if err != nil { return nil, err } if len(container.FlavorsDetail) < defaultLimit { more = false } for _, flavorDetail := range container.FlavorsDetail { result = append(result, flavorDetail) marker = flavorDetail.ID } } return result, err }
// Subnets issues a GET request to return all subnets. func (networkService Service) Subnets() ([]SubnetResponse, error) { var sn = subnetsResp{} reqURL, err := networkService.buildRequestURL("/subnets") if err != nil { return sn.Subnets, err } err = misc.GetJSON(reqURL, networkService.authenticator, &sn) return sn.Subnets, err }
// Subnet issues a GET request to a specific url of a subnet and returns a subnet response. func (networkService Service) Subnet(id string) (SubnetResponse, error) { subnetContainer := subnetResp{} reqURL, err := networkService.buildRequestURL("/subnets/", id) if err != nil { return subnetContainer.Subnet, err } err = misc.GetJSON(reqURL, networkService.authenticator, &subnetContainer) return subnetContainer.Subnet, err }
// Limits will issue a get request to retrieve the all limits for the user. func (computeService Service) Limits() (Limits, error) { var limits = limitsContainer{} reqURL, err := computeService.buildRequestURL("/limits") if err != nil { return limits.Limits, err } err = misc.GetJSON(reqURL, computeService.authenticator, &limits) return limits.Limits, err }
// Volume will issue a GET request to retrieve the volume by id. func (blockStorageService Service) Volume(id string) (Volume, error) { c := volumeContainer{Volume: Volume{}} url, err := blockStorageService.buildRequestURL("/volumes/", id) if err != nil { return c.Volume, err } err = misc.GetJSON(url, blockStorageService.authenticator, &c) return c.Volume, err }
// SecurityGroup will issue a get query that returns a security group based on the id. func (computeService Service) SecurityGroup(id string) (SecurityGroup, error) { var r = securityGroupContainer{} reqURL, err := computeService.buildRequestURL("/os-security-groups/", id) if err != nil { return r.SecurityGroup, err } err = misc.GetJSON(reqURL, computeService.authenticator, &r) return r.SecurityGroup, err }
// FlavorDetail will issue a GET request to retrieve the specified flavor detail. func (computeService Service) FlavorDetail(flavorID string) (FlavorDetail, error) { var container = FlavorDetailContainer{} url, err := computeService.buildRequestURL("/flavors/", flavorID) if err != nil { return container.FlavorDetail, err } err = misc.GetJSON(url, computeService.authenticator, &container) return container.FlavorDetail, err }
// FloatingIP will issue a get query that returns a floating ip. func (computeService Service) FloatingIP(id string) (FloatingIP, error) { var r = floatingIPResp{} reqURL, err := computeService.buildRequestURL("/os-floating-ips/", id) if err != nil { return r.FloatingIP, err } err = misc.GetJSON(reqURL, computeService.authenticator, &r) return r.FloatingIP, err }
// Instance will issue a GET request to retrieve the specified database instance. func (databaseService Service) Instance(instanceID string) (InstanceDetail, error) { var container = InstanceDetailContainer{} reqURL, err := databaseService.buildRequestURL("/instances/", instanceID) if err != nil { return container.Instance, err } err = misc.GetJSON(reqURL, databaseService.authenticator, &container) return container.Instance, err }
// ServerSecurityGroups will issue a get query that returns the security groups for the specified server. func (computeService Service) ServerSecurityGroups(serverID string) ([]SecurityGroup, error) { var r = SecurityGroupsContainer{} reqURL, err := computeService.buildRequestURL("/os-security-groups", "/servers/", serverID) if err != nil { return r.SecurityGroups, err } err = misc.GetJSON(reqURL, computeService.authenticator, &r) return r.SecurityGroups, err }
// Port issues a GET request that returns a specific port response. func (networkService Service) Port(id string) (PortResponse, error) { port := portResp{} reqURL, err := networkService.buildRequestURL("/ports/", id) if err != nil { return port.Port, err } err = misc.GetJSON(reqURL, networkService.authenticator, &port) return port.Port, err }
// Volumes will issue a GET request to retrieve the volumes. func (blockStorageService Service) Volumes() ([]Volume, error) { c := map[string][]Volume{"json:volumes": []Volume{}} url, err := blockStorageService.buildRequestURL("/volumes") if err != nil { return c["volumes"], err } err = misc.GetJSON(url, blockStorageService.authenticator, &c) return c["volumes"], err }
// Backup will issue a GET request to retrieve the specified backup. func (databaseService Service) Backup(backupID string) (Backup, error) { var container = backupContainer{} reqURL, err := databaseService.buildRequestURL("/backups/", backupID) if err != nil { return container.Backup, err } err = misc.GetJSON(reqURL, databaseService.authenticator, &container) return container.Backup, err }
// Backups will issue a GET request to retrieve all backups. func (databaseService Service) Backups() ([]Backup, error) { var container = backupsContainer{} reqURL, err := databaseService.buildRequestURL("/backups") if err != nil { return container.Backups, err } err = misc.GetJSON(reqURL, databaseService.authenticator, &container) return container.Backups, err }
// Router will issue a get query that returns a security group based on the id. func (networkService Service) Router(id string) (Router, error) { r := routerContainer{} reqURL, err := networkService.buildRequestURL("/routers/", id) if err != nil { return r.Router, err } err = misc.GetJSON(reqURL, networkService.authenticator, &r) return r.Router, err }
// Routers will issue a get query that returns a list of security groups in the system. func (networkService Service) Routers() ([]Router, error) { r := routersContainer{} reqURL, err := networkService.buildRequestURL("/routers") if err != nil { return r.Routers, err } err = misc.GetJSON(reqURL, networkService.authenticator, &r) return r.Routers, err }
// Users will issue a GET request to retrieve information of all users. func (databaseService Service) Users(instanceID string) ([]User, error) { var container = UsersContainer{} reqURL, err := databaseService.buildRequestURL("/instances/", instanceID, "/users") if err != nil { return container.Users, err } err = misc.GetJSON(reqURL, databaseService.authenticator, &container) return container.Users, err }
// Instances will issue a GET request to retrieve all database instances. func (databaseService Service) Instances() ([]Instance, error) { var container = InstancesContainer{} reqURL, err := databaseService.buildRequestURL("/instances") if err != nil { return container.Instances, err } err = misc.GetJSON(reqURL, databaseService.authenticator, &container) return container.Instances, err }
// SecurityGroup will retrieve a single security group from Neutron func (networkService Service) SecurityGroup(id string) (SecurityGroup, error) { respContainer := securityGroupContainer{} reqURL, err := networkService.buildRequestURL("/security-groups/", id) if err != nil { return SecurityGroup{}, err } err = misc.GetJSON(reqURL, networkService.authenticator, &respContainer) if err != nil { return SecurityGroup{}, err } return respContainer.SecurityGroup, nil }
// SecurityGroups will retrieve a list of security groups from Neutron func (networkService Service) SecurityGroups() ([]SecurityGroup, error) { respContainer := securityGroupsResponse{} reqURL, err := networkService.buildRequestURL("/security-groups") if err != nil { return []SecurityGroup{}, err } err = misc.GetJSON(reqURL, networkService.authenticator, &respContainer) if err != nil { return []SecurityGroup{}, err } return respContainer.SecurityGroups, nil }
// Ports issues a GET request that returns the found port responses func (networkService Service) Ports() ([]PortResponse, error) { p := portsResp{} reqURL, err := networkService.buildRequestURL("/ports") if err != nil { return p.Ports, err } err = misc.GetJSON(reqURL, networkService.authenticator, &p) if err != nil { return nil, err } return p.Ports, nil }
// AvailabilityZones will issue a GET request to retrieve all availability zones. func (computeService Service) AvailabilityZones() ([]AvailabilityZone, error) { var container = AvailabilityZonesContainer{} url, err := computeService.buildRequestURL("/os-availability-zone") if err != nil { return container.AvailabilityZones, err } err = misc.GetJSON(url, computeService.authenticator, &container) if err != nil { return nil, err } return container.AvailabilityZones, err }
func (service Service) queryImages(includeDetails bool, imagesResponseContainer interface{}, queryParameters QueryParameters) error { urlPostFix := "/images" if includeDetails { urlPostFix = urlPostFix + "/detail" } reqURL, err := buildQueryURL(service, queryParameters, urlPostFix) if err != nil { return err } err = misc.GetJSON(reqURL.String(), service.authenticator, &imagesResponseContainer) if err != nil { return err } return nil }