Cleaning up eslint warnings in the openstack-service-api directory

There are many eslint warnings in this directory.  This patch cleans
them up, about 100 warnings removed.

Change-Id: I639dccd7b511190552f05ae0e52234532412e54c
Partial-Bug: 1554824
This commit is contained in:
Matt Borland 2016-03-09 11:07:40 -07:00
parent 2685a624ee
commit 09148f68d6
20 changed files with 283 additions and 123 deletions

View File

@ -26,7 +26,10 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.cinderExtensions
* @name cinderExtensions
* @param {Object} $cacheFactory
* @param {Object} extensionsAPI
* @param {Object} cinderAPI
* @description
* Provides cached access to Cinder Extensions with utilities to help
* with asynchronous data loading. The cache may be reset at any time
@ -36,6 +39,7 @@
* The enabled extensions do not change often, so using cached data will
* speed up results. Even on a local devstack in informal testing,
* this saved between 30 - 100 ms per request.
* @returns {Object} The service
*/
function cinderExtensionsAPI($cacheFactory, extensionsAPI, cinderAPI) {
return extensionsAPI({

View File

@ -27,8 +27,11 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.cinder
* @param {Object} apiService
* @param {Object} toastService
* @name cinder
* @description Provides direct access to Cinder APIs.
* @returns {Object} The service
*/
function cinderAPI(apiService, toastService) {
var service = {
@ -52,7 +55,7 @@
// Volumes
/**
* @name horizon.app.core.openstack-service-api.cinder.getVolumes
* @name getVolumes
* @description
* Get a list of volumes.
*
@ -80,6 +83,7 @@
* @param {string} param.search_opts
* Filters to pass through the API.
* For example, "status": "available" will show all available volumes.
* @returns {Object} The result of the API call
*/
function getVolumes(params) {
var config = params ? {'params': params} : {};
@ -90,13 +94,14 @@
}
/**
* @name horizon.app.core.openstack-service-api.cinder.getVolume
* @name getVolume
* @description
* Get a single Volume by ID.
*
* @param {string} id
* Specifies the id of the Volume to request.
*
* @returns {Object} The result of the API call
*/
function getVolume(id) {
return apiService.get('/api/cinder/volumes/' + id)
@ -106,9 +111,11 @@
}
/**
* @name horizon.app.core.openstack-service-api.cinder.createVolume
* @name createVolume
* @param {Object} newVolume - The new volume object
* @description
* Create a volume.
* @returns {Object} The result of the API call
*/
function createVolume(newVolume) {
return apiService.post('/api/cinder/volumes/', newVolume)
@ -120,13 +127,14 @@
// Volume Types
/**
* @name horizon.app.core.openstack-service-api.cinder.getVolumeTypes
* @name getVolumeTypes
* @description
* Get a list of volume types.
*
* The listing result is an object with property "items." Each item is
* a volume type.
*
* @returns {Object} The result of the API call
*/
function getVolumeTypes() {
return apiService.get('/api/cinder/volumetypes/')
@ -136,13 +144,14 @@
}
/**
* @name horizon.app.core.openstack-service-api.cinder.getVolumeType
* @name getVolumeType
* @description
* Get a single Volume Type by ID.
*
* @param {string} id
* Specifies the id of the Volume Type to request.
*
* @returns {Object} The result of the API call
*/
function getVolumeType(id) {
return apiService.get('/api/cinder/volumetypes/' + id)
@ -152,10 +161,11 @@
}
/**
* @name horizon.app.core.openstack-service-api.cinder.getDefaultVolumeType
* @name getDefaultVolumeType
* @description
* Get the default Volume Type
*
* @returns {Object} The result of the API call
*/
function getDefaultVolumeType() {
return apiService.get('/api/cinder/volumetypes/default')
@ -167,7 +177,7 @@
// Volume Snapshots
/**
* @name horizon.app.core.openstack-service-api.cinder.getVolumeSnapshots
* @name getVolumeSnapshots
* @description
* Get a list of volume snapshots.
*
@ -181,6 +191,7 @@
* Filters to pass through the API.
* For example, "status": "available" will show all available volume
* snapshots.
* @returns {Object} The result of the API call
*/
function getVolumeSnapshots(params) {
var config = params ? {'params': params} : {};
@ -194,7 +205,8 @@
// Cinder Extensions
/**
* @name horizon.app.core.openstack-service-api.cinder.getExtensions
* @name getExtensions
* @param {Object} config - The configuration for retrieving the extensions
* @description
* Returns a list of enabled extensions.
*
@ -215,6 +227,7 @@
* }
* ]
* }
* @returns {Object} The result of the API call
*/
function getExtensions(config) {
return apiService.get('/api/cinder/extensions/', config)
@ -226,10 +239,10 @@
// Cinder Services
/**
* @name horizon.openstack-service-api.cinder.getServices
* @name getServices
* @description Get the list of Cinder services.
*
* @returns The listing result is an object with property "services." Each item is
* @returns {Object} An object with property "services." Each item is
* a service.
*/
function getServices() {
@ -240,7 +253,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.cinder.getQoSSpecs
* @name getQoSSpecs
* @description
* Get a list of Quality of Service.
*
@ -249,6 +262,7 @@
*
* @param {Object} params
* Query parameters. Optional.
* @returns {Object} The result of the API call
*
*/
function getQoSSpecs(params) {
@ -261,10 +275,11 @@
}
/**
* @name horizon.app.core.openstack-service-api.cinder.getAbsoluteLimits
* @name getAbsoluteLimits
* @description
* Get the limits for the current tenant.
*
* @returns {Object} The result of the API call
*/
function getAbsoluteLimits() {
return apiService.get('/api/cinder/tenantabsolutelimits/')

View File

@ -26,7 +26,8 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.extensions
* @name extensions
* @param {Object} $q
* @description
* Provides cached access to Extensions with utilities to help
* with asynchronous data loading. The cache may be reset at any time
@ -39,6 +40,7 @@
*
* This is modeled to be used by other Openstack Services not directly.
*
* @returns {Object} The service
*/
function extensions($q) {
return function(spec) {

View File

@ -27,8 +27,11 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.glance
* @name glance
* @param {Object} apiService
* @param {Object} toastService
* @description Provides direct pass through to Glance with NO abstraction.
* @returns {Object} The service
*/
function glanceAPI(apiService, toastService) {
var service = {
@ -51,9 +54,10 @@
// Version
/**
* @name horizon.app.core.openstack-service-api.glance.getVersion
* @name getVersion
* @description
* Get the version of the Glance API
* @returns {Object} The result of the API call
*/
function getVersion() {
return apiService.get('/api/glance/version/')
@ -65,13 +69,14 @@
// Images
/**
* @name horizon.app.core.openstack-service-api.glance.getImage
* @name getImage
* @description
* Get a single image by ID
*
* @param {string} id
* Specifies the id of the image to request.
*
* @returns {Object} The result of the API call
*/
function getImage(id) {
return apiService.get('/api/glance/images/' + id + '/')
@ -81,7 +86,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.glance.createImage
* @name createImage
* @description
* Create a new image. This returns the new image object on success.
*
@ -127,6 +132,7 @@
*
* Any parameters not listed above will be assigned as custom properites.
*
* @returns {Object} The result of the API call
*/
function createImage(image) {
return apiService.post('/api/glance/images/', image)
@ -136,7 +142,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.glance.getImage
* @name getImage
* @description
* Update an existing image.
*
@ -177,6 +183,7 @@
* True if the image is protected, false otherwise. Required.
*
* Any parameters not listed above will be assigned as custom properites.
* @returns {Object} The result of the API call
*/
function updateImage(image) {
return apiService.patch('/api/glance/images/' + image.id + '/', image)
@ -186,7 +193,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.glance.deleteImage
* @name deleteImage
* @description
* Deletes single Image by ID.
*
@ -196,6 +203,7 @@
* @param {boolean} suppressError
* If passed in, this will not show the default error handling
*
* @returns {Object} The result of the API call
*/
function deleteImage(imageId, suppressError) {
var promise = apiService.delete('/api/glance/images/' + imageId + '/');
@ -207,10 +215,11 @@
}
/**
* @name horizon.app.core.openstack-service-api.glance.getImageProps
* @name getImageProps
* @description
* Get an image custom properties by image ID
* @param {string} id Specifies the id of the image to request.
* @returns {Object} The result of the API call
*/
function getImageProps(id) {
return apiService.get('/api/glance/images/' + id + '/properties/')
@ -220,12 +229,13 @@
}
/**
* @name horizon.app.core.openstack-service-api.glance.editImageProps
* @name editImageProps
* @description
* Update an image custom properties by image ID
* @param {string} id Specifies the id of the image to request.
* @param {object} updated New metadata definitions.
* @param {[]} removed Names of removed metadata definitions.
* @returns {Object} The result of the API call
*/
function editImageProps(id, updated, removed) {
return apiService.patch(
@ -241,7 +251,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.glance.getImages
* @name getImages
* @description
* Get a list of images.
*
@ -273,6 +283,7 @@
* @param {string} params.other
* Any additional request parameters will be passed through the API as
* filters. For example "name" : "fedora" would filter on the fedora name.
* @returns {Object} The result of the API call
*/
function getImages(params) {
var config = params ? { 'params' : params} : {};
@ -285,7 +296,7 @@
// Metadata Definitions - Namespaces
/**
* @name horizon.app.core.openstack-service-api.glance.getNamespaces
* @name getNamespaces
* @description
* Get a list of metadata definition namespaces.
*
@ -338,6 +349,7 @@
* If passed in, this will not show the default error handling
* (horizon alert). The glance API may not have metadata definitions
* enabled.
* @returns {Object} The result of the API call
*/
function getNamespaces(params, suppressError) {
var config = params ? {'params' : params} : {};
@ -351,7 +363,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.glance.getResourceTypes
* @name getResourceTypes
* @description
* Get a list of metadata definition resource types.
*
@ -362,6 +374,7 @@
* correlate to Heat and Searchlight resource types.
* For example: OS::Glance::Image and OS::Nova::Server.
*
* @returns {Object} The result of the API call
*/
function getResourceTypes() {
var config = {

View File

@ -27,8 +27,11 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.heat
* @name heatAPI
* @param {Object} apiService
* @param {Object} toastService
* @description Provides direct pass through to Heat with NO abstraction.
* @returns {Object} The service
*/
function heatAPI(apiService, toastService) {
var service = {
@ -39,18 +42,18 @@
return service;
/**
* @name horizon.app.core.openstack-service-api.heat.validate
* @name validate
* @description
* Validate a template.
*
* The result is an object.
*
* @param {string} params.template_url
* @param {string} params
* - template_url
* Specifies the template to validate.
*
* @param {boolean} suppressError
* If passed in, this will not show the default error handling
* (horizon alert).
* @returns {Object} The result of the API call
*/
function validate(params, suppressError) {
var promise = apiService.post('/api/heat/validate/', params);
@ -60,10 +63,10 @@
}
/**
* @name horizon.openstack-service-api.heat.getServices
* @name getServices
* @description Get the list of heat services.
*
* @returns The listing result is an object with property "services." Each item is
* @returns {Object} The listing result is an object with property "services." Each item is
* a service.
*/
function getServices() {

View File

@ -72,6 +72,7 @@
* with the class of 'download-iframes' is present.
*
* @param {string} name The desired name for the key pair
* @returns {promise} A promise resolving if true, rejecting with error
*/
function createAndDownloadKeypair(name) {
addDOMResource(name);
@ -87,6 +88,7 @@
* the appropriate URL for the API to create/download the new key pair.
*
* @param {string} keypairName The desired name for the key pair
* @returns {undefined} Returns nothing
*/
function addDOMResource(keypairName) {
var url = novaAPI.getCreateKeypairUrl(keypairName);
@ -113,6 +115,7 @@
* period, the promise is rejected.
*
* @param {string} name The name for the key pair
* @returns {promise} A promise resolving if true, rejecting with error
*/
function verifyCreatedPromise(name) {
return $q(function doesKeypairExistPromise(resolve, reject) {

View File

@ -101,7 +101,8 @@
}
/**
* @name horizon.app.core.openstack-service-api.keystone.getCurrentUserSession
* @name getCurrentUserSession
* @param {Object} config - The configuration for which we want a session
* @description
* Gets the current User Session Information
* @example
@ -126,6 +127,7 @@
* "user_domain_name": "Default",
* "username": "admin"
* }
* @returns {Object} The result of the API call
*/
function getCurrentUserSession(config) {
return apiService.get('/api/keystone/user-session/', config)
@ -299,11 +301,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.keystone.serviceCatalog
* @name serviceCatalog
* @description
* Returns the service catalog.
* @param {Object} config
* See $http config object parameters.
* @returns {Object} The result of the API call
*/
function serviceCatalog(config) {
return apiService.get('/api/keystone/svc-catalog/', config)

View File

@ -27,9 +27,12 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.network
* @name networkAPI
* @param {Object} apiService
* @param {Object} toastService
* @description Provides access to APIs that are common to nova network
* and neutron.
* @returns {Object} The service
*/
function networkAPI(apiService, toastService) {
var service = {
@ -47,11 +50,11 @@
// Floating IPs
/**
* @name horizon.app.core.openstack-service-api.networkAPI.getFloatingIps
* @name getFloatingIps
* @description
* Get a list of floating IP addresses.
*
* The listing result is an object with property "items". Each item is
* @returns {Object} An object with property "items". Each item is
* a floating IP address.
*/
function getFloatingIps() {
@ -62,11 +65,11 @@
}
/**
* @name horizon.app.core.openstack-service-api.networkAPI.getFloatingIpPools
* @name getFloatingIpPools
* @description
* Get a list of floating IP pools.
*
* The listing result is an object with property "items". Each item is
* @returns {Object} An object with property "items". Each item is
* a floating IP address.
*/
function getFloatingIpPools() {
@ -77,14 +80,14 @@
}
/**
* @name horizon.app.core.openstack-service-api.networkAPI.allocateFloatingIp
* @name allocateFloatingIp
* @description
* Allocate a floating IP address within a pool.
*
* @param {string} poolId
* The Id of the pool in which to allocate the new floating IP address.
*
* Returns the new floating IP address on success.
* @returns {Object} the new floating IP address on success.
*/
function allocateFloatingIp(poolId) {
return apiService.post('/api/network/floatingip/', { pool_id: poolId })
@ -94,7 +97,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.networkAPI.associateFloatingIp
* @name associateFloatingIp
* @description
* Associate a floating IP address with a port.
*
@ -103,6 +106,7 @@
*
* @param {string} portId
* The Id of the port to associate.
* @returns {Object} The result of the API call
*/
function associateFloatingIp(addressId, portId) {
var params = { address_id: addressId, port_id: portId };
@ -113,12 +117,13 @@
}
/**
* @name horizon.app.core.openstack-service-api.networkAPI.disassociateFloatingIp
* @name disassociateFloatingIp
* @description
* Disassociate a floating IP address.
*
* @param {string} addressId
* The Id of the floating IP address to disassociate.
* @returns {Object} The result of the API call
*/
function disassociateFloatingIp(addressId) {
return apiService.patch('/api/network/floatingip/', { address_id: addressId })

View File

@ -27,7 +27,10 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.neutronExtensions
* @name neutronExtensionsAPI
* @param {Object} $cacheFactory
* @param {Object} extensions
* @param {Object} neutron
* @description
* Provides cached access to Neutron Extensions with utilities to help
* with asynchronous data loading. The cache may be reset at any time
@ -37,6 +40,7 @@
* The enabled extensions do not change often, so using cached data will
* speed up results. Even on a local devstack in informal testing,
* this saved between 30 - 100 ms per request.
* @returns {Object} The service
*/
function neutronExtensionsAPI($cacheFactory, extensions, neutron) {
return extensions({

View File

@ -21,9 +21,19 @@
beforeEach(module('horizon.app.core.openstack-service-api'));
beforeEach(module(function($provide) {
neutron = {getExtensions: function() {return {then: angular.noop}; }};
q = {defer: function() { return {resolve: angular.noop}; }};
$provide.value('$cacheFactory', function() {return "cache"; });
neutron = {
getExtensions: function() {
return {
then: angular.noop
};
}
};
q = {defer: function() {
return {resolve: angular.noop};
}};
$provide.value('$cacheFactory', function() {
return "cache";
});
$provide.value('$q', q);
$provide.value('horizon.app.core.openstack-service-api.neutron', neutron);
}));

View File

@ -27,8 +27,11 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.neutron
* @name neutronAPI
* @param {Object} apiService
* @param {Object} toastService
* @description Provides access to Neutron APIs.
* @returns {Object} The service
*/
function neutronAPI(apiService, toastService) {
var service = {
@ -48,11 +51,10 @@
// Neutron Services
/**
* @name horizon.openstack-service-api.neutron.getAgents
* @name getAgents
* @description Get the list of Neutron agents.
*
* @returns The listing result is an object with property "items." Each item is
* an agent.
* @returns {Object} An object with property "items." Each item is an agent.
*/
function getAgents() {
return apiService.get('/api/neutron/agents/')
@ -64,12 +66,11 @@
// Networks
/**
* @name horizon.app.core.openstack-service-api.neturonAPI.getNetworks
* @name getNetworks
* @description
* Get a list of networks for a tenant.
*
* The listing result is an object with property "items". Each item is
* a network.
* @returns {Object} An object with property "items". Each item is a network.
*/
function getNetworks() {
return apiService.get('/api/neutron/networks/')
@ -79,10 +80,10 @@
}
/**
* @name horizon.app.core.openstack-service-api.neutron.createNetwork
* @name createNetwork
* @description
* Create a new network.
* @returns The new network object on success.
* @returns {Object} The new network object on success.
*
* @param {Object} newNetwork
* The network to create. Required.
@ -130,7 +131,7 @@
// Subnets
/**
* @name horizon.app.core.openstack-service-api.neutron.getSubnets
* @name getSubnets
* @description
* Get a list of subnets for a network.
*
@ -139,6 +140,7 @@
*
* @param {string} networkId
* The network id to retrieve subnets for. Required.
* @returns {Object} The result of the API call
*/
function getSubnets(networkId) {
return apiService.get('/api/neutron/subnets/', networkId)
@ -148,10 +150,10 @@
}
/**
* @name horizon.app.core.openstack-service-api.neutron.createSubnet
* @name createSubnet
* @description
* Create a Subnet for given Network.
* @returns The JSON representation of Subnet on success.
* @returns {Object} The JSON representation of Subnet on success.
*
* @param {Object} newSubnet
* The subnet to create.
@ -214,13 +216,14 @@
// Ports
/**
* @name horizon.app.core.openstack-service-api.neutron.getPorts
* @name getPorts
* @description
* Get a list of ports for a network.
*
* The listing result is an object with property "items". Each item is
* a port.
*
* @param {string} params - The parameters
* @param {string} params.status
* The port status. Value is ACTIVE or DOWN.
*
@ -253,9 +256,10 @@
* @param {string} params.device_id
* The UUID of the device that uses this port. For example, a virtual server.
*
* @returns {Object} The result of the API call
*/
function getPorts(params) {
var config = (params) ? { 'params' : params} : {};
var config = params ? { 'params' : params} : {};
return apiService.get('/api/neutron/ports/', config)
.error(function () {
toastService.add('error', gettext('Unable to retrieve the ports.'));
@ -265,7 +269,7 @@
// Extensions
/**
* @name horizon.app.core.openstack-services-api.neutron.getExtensions
* @name getExtensions
* @description
* Returns a list of enabled extensions.
*
@ -285,6 +289,7 @@
* }
* ]
* }
* @returns {Object} The result of the API call
*/
function getExtensions() {
return apiService.get('/api/neutron/extensions/')

View File

@ -28,7 +28,10 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.novaExtensions
* @name novaExtensionsAPI
* @param {Object} $cacheFactory
* @param {Object} extensionsAPI
* @param {Object} novaAPI
* @description
* Provides cached access to Nova Extensions with utilities to help
* with asynchronous data loading. The cache may be reset at any time
@ -38,6 +41,7 @@
* The enabled extensions do not change often, so using cached data will
* speed up results. Even on a local devstack in informal testing,
* this saved between 30 - 100 ms per request.
* @returns {Object} The service
*/
function novaExtensionsAPI($cacheFactory, extensionsAPI, novaAPI) {
return extensionsAPI({

View File

@ -29,8 +29,12 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.nova
* @param {Object} apiService
* @param {Object} toastService
* @param {Object} $window
* @name novaApi
* @description Provides access to Nova APIs.
* @returns {Object} The service
*/
function novaAPI(apiService, toastService, $window) {
@ -66,10 +70,10 @@
// Nova Services
/**
* @name horizon.openstack-service-api.nova.getServices
* @name getServices
* @description Get the list of Nova services.
*
* @returns The listing result is an object with property "services." Each item is
* @returns {Object} The listing result is an object with property "services." Each item is
* a service.
*/
function getServices() {
@ -82,12 +86,11 @@
// Keypairs
/**
* @name horizon.app.core.openstack-service-api.nova.getKeypairs
* @name getKeypairs
* @description
* Get a list of keypairs.
*
* The listing result is an object with property "items". Each item is
* a keypair.
* @returns {Object} An object with property "items". Each item is a keypair.
*/
function getKeypairs() {
return apiService.get('/api/nova/keypairs/')
@ -97,7 +100,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.createKeypair
* @name createKeypair
* @description
* Create a new keypair. This returns the new keypair object on success.
*
@ -109,6 +112,7 @@
*
* @param {string} newKeypair.public_key
* The public key. Optional.
* @returns {Object} The result of the API call
*/
function createKeypair(newKeypair) {
return apiService.post('/api/nova/keypairs/', newKeypair)
@ -124,12 +128,13 @@
// Availability Zones
/**
* @name horizon.app.core.openstack-service-api.nova.getAvailabilityZones
* @name getAvailabilityZones
* @description
* Get a list of Availability Zones.
*
* The listing result is an object with property "items". Each item is
* an availability zone.
* @returns {Object} The result of the API call
*/
function getAvailabilityZones() {
return apiService.get('/api/nova/availzones/')
@ -142,7 +147,7 @@
// Limits
/**
* @name horizon.app.core.openstack-service-api.nova.getLimits
* @name getLimits
* @description
* Returns current limits.
*
@ -169,6 +174,7 @@
* "totalSecurityGroupsUsed": 1,
* "totalServerGroupsUsed": 0
* }
* @returns {Object} The result of the API call
*/
function getLimits() {
return apiService.get('/api/nova/limits/')
@ -180,7 +186,8 @@
// Servers
/**
* @name horizon.app.core.openstack-service-api.nova.createServer
* @name createServer
* @param {Object} newServer - The new server
* @description
* Create a server using the parameters supplied in the
* newServer. The required parameters:
@ -195,7 +202,7 @@
* "availability_zone", "instance_count", "admin_pass", "disk_config",
* "config_drive"
*
* This returns the new server object on success.
* @returns {Object} The result of the API call
*/
function createServer(newServer) {
return apiService.post('/api/nova/servers/', newServer)
@ -205,11 +212,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.getServer
* @name getServer
* @description
* Get a single server by ID
* @param {string} id
* Specifies the id of the server to request.
* @returns {Object} The result of the API call
*/
function getServer(id) {
return apiService.get('/api/nova/servers/' + id)
@ -219,12 +227,13 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.getServers
* @name getServers
* @description
* Get a list of servers.
*
* The listing result is an object with property "items". Each item is
* a server.
* @returns {Object} The result of the API call
*/
function getServers() {
return apiService.get('/api/nova/servers/')
@ -234,7 +243,8 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.getExtensions
* @name getExtensions
* @param {Object} config - A configuration object
* @description
* Returns a list of enabled extensions.
*
@ -255,6 +265,7 @@
* }
* ]
* }
* @returns {Object} The list of enable extensions
*/
function getExtensions(config) {
return apiService.get('/api/nova/extensions/', config)
@ -264,7 +275,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.getFlavors
* @name getFlavors
* @description
* Returns a list of flavors.
*
@ -278,6 +289,7 @@
* @param {boolean} getExtras (optional)
* Also retrieve the extra specs. This is expensive (one extra underlying
* call per flavor).
* @returns {Object} The result of the API call
*/
function getFlavors(isPublic, getExtras) {
var config = {'params': {}};
@ -313,13 +325,15 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.getFlavor
* @name getFlavor
* @description
* Get a single flavor by ID.
* @param {string} id
* Specifies the id of the flavor to request.
* @param {boolean} getExtras (optional)
* Also retrieve the extra specs for the flavor.
* @param {boolean} getAccessList - True if you want get the access list
* @returns {Object} The result of the API call
*/
function getFlavor(id, getExtras, getAccessList) {
var config = {'params': {}};
@ -336,11 +350,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.createFlavor
* @name createFlavor
* @description
* Create a single flavor.
* @param {flavor} flavor
* Flavor to create
* @returns {Object} The result of the API call
*/
function createFlavor(flavor) {
return apiService.post('/api/nova/flavors/', flavor)
@ -350,11 +365,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.updateFlavor
* @name updateFlavor
* @description
* Update a single flavor.
* @param {flavor} flavor
* Flavor to update
* @returns {Object} The result of the API call
*/
function updateFlavor(flavor) {
return apiService.patch('/api/nova/flavors/' + flavor.id + '/', flavor)
@ -364,7 +380,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.deleteFlavor
* @name deleteFlavor
* @description
* Delete a single flavor by ID.
*
@ -375,6 +391,7 @@
* If passed in, this will not show the default error handling
* (horizon alert). The glance API may not have metadata definitions
* enabled.
* @returns {Object} The result of the API call
*/
function deleteFlavor(flavorId, suppressError) {
var promise = apiService.delete('/api/nova/flavors/' + flavorId + '/');
@ -387,11 +404,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.getFlavorExtraSpecs
* @name getFlavorExtraSpecs
* @description
* Get a single flavor's extra specs by ID.
* @param {string} id
* Specifies the id of the flavor to request the extra specs.
* @returns {Object} The result of the API call
*/
function getFlavorExtraSpecs(id) {
return apiService.get('/api/nova/flavors/' + id + '/extra-specs/')
@ -401,12 +419,13 @@
}
/**
* @name horizon.openstack-service-api.nova.editFlavorExtraSpecs
* @name editFlavorExtraSpecs
* @description
* Update a single flavor's extra specs by ID.
* @param {string} id
* @param {object} updated New extra specs.
* @param {[]} removed Names of removed extra specs.
* @returns {Object} The result of the API call
*/
function editFlavorExtraSpecs(id, updated, removed) {
return apiService.patch(
@ -421,11 +440,12 @@
}
/**
* @name horizon.openstack-service-api.nova.getAggregateExtraSpecs
* @name getAggregateExtraSpecs
* @description
* Get a single aggregate's extra specs by ID.
* @param {string} id
* Specifies the id of the flavor to request the extra specs.
* @returns {Object} The result of the API call
*/
function getAggregateExtraSpecs(id) {
return apiService.get('/api/nova/aggregates/' + id + '/extra-specs/')
@ -435,12 +455,13 @@
}
/**
* @name horizon.openstack-service-api.nova.editAggregateExtraSpecs
* @name editAggregateExtraSpecs
* @description
* Update a single aggregate's extra specs by ID.
* @param {string} id
* @param {object} updated New extra specs.
* @param {[]} removed Names of removed extra specs.
* @returns {Object} The result of the API call
*/
function editAggregateExtraSpecs(id, updated, removed) {
return apiService.patch(
@ -455,11 +476,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.nova.getInstanceMetadata
* @name getInstanceMetadata
* @description
* Get a single instance's metadata by ID.
* @param {string} id
* Specifies the id of the instance to request the metadata.
* @returns {Object} The result of the API call
*/
function getInstanceMetadata(id) {
return apiService.get('/api/nova/servers/' + id + '/metadata')
@ -469,12 +491,13 @@
}
/**
* @name horizon.openstack-service-api.nova.editInstanceMetadata
* @name editInstanceMetadata
* @description
* Update a single instance's metadata by ID.
* @param {string} id
* @param {object} updated New metadata.
* @param {[]} removed Names of removed metadata items.
* @returns {Object} The result of the API call
*/
function editInstanceMetadata(id, updated, removed) {
return apiService.patch(
@ -500,6 +523,7 @@
* the key pair download service).
*
* @param {string} keyPairName
* @returns {Object} The result of the API call
*/
function getCreateKeypairUrl(keyPairName) {
// NOTE: WEBROOT by definition must end with a slash (local_settings.py).
@ -519,6 +543,7 @@
* (which is further explained in the key pair download service).
*
* @param {string} keyPairName
* @returns {Object} The result of the API call
*/
function getRegenerateKeypairUrl(keyPairName) {
return getCreateKeypairUrl(keyPairName) + "?regenerate=true";

View File

@ -28,9 +28,13 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.policy
* @name PolicyService
* @param {Object} $q
* @param {Object} apiService
* @param {Object} toastService
* @description Provides a direct pass through to the policy engine in
* Horizon.
* @returns {Object} The service
*/
function PolicyService($cacheFactory, $q, apiService, toastService) {
@ -48,7 +52,8 @@
//////////////
/**
* @name horizon.app.core.openstack-service-api.policy.check
* @name check
* @param {Object} policyRules
* @description
* Check the passed in policy rule list to determine if the user has
* permission to perform the actions specified by the rules. The service
@ -83,6 +88,7 @@
* {
* "allowed": false
* }
* @returns {Object} The result of the API call
*/
function check(policyRules) {
// Return a deferred and map then to success since legacy angular http uses success.
@ -112,6 +118,7 @@
/**
* @name ifAllowed
* @param {Object} policyRules
* @description
* Wrapper function for check that returns a deferred promise.
* Resolves if the response is allowed, rejects otherwise.
@ -125,6 +132,7 @@
```js
policyService.ifAllowed(myRules).then(deleteObject, doSomethingElse);
```
* @returns {promise} A promise resolving if true, rejecting if not
*/
function ifAllowed(policyRules) {
var deferred = $q.defer();

View File

@ -27,8 +27,11 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.security-group
* @name securityGroupAPI
* @param {Object} apiService
* @param {Object} toastService
* @description Provides access to Security Groups
* @returns {Object} The service
*/
function securityGroupAPI(apiService, toastService) {
var service = {
@ -40,7 +43,7 @@
///////////////
/**
* @name horizon.app.core.openstack-service-api.security-group.list
* @name list
* @description
* Get a list of security groups.
*
@ -73,6 +76,7 @@
* }
* ]
* }
* @returns {Object} The result of the API call
*/
function query() {
return apiService.get('/api/network/securitygroups/')

View File

@ -29,7 +29,11 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.serviceCatalog
* @name serviceCatalog
* @param {Object} $cacheFactory
* @param {Object} $q
* @param {Object} keystoneAPI
* @param {Object} userSession
* @description
* Provides cached access to the Service Catalog with utilities to help
* with asynchronous data loading. The cache may be reset at any time
@ -46,6 +50,7 @@
* particular page or modal. Making this a service allows it to be injected
* and used transparently where needed without making every single use of it
* pass it through as an argument.
* @returns {Object} The service
*/
function serviceCatalog($cacheFactory, $q, keystoneAPI, userSession) {
@ -63,15 +68,15 @@
////////////
/**
* @name horizon.app.core.openstack-service-api.serviceCatalog.get
* @name get
* @description
* Returns the service catalog. This is cached.
*
* @example
*
```js
serviceCatalog.get().then(doSomething, doSomethingElse);
```
* @returns {Object} The service catalog. This is cached.
*/
function get() {
return keystoneAPI.serviceCatalog({cache: service.cache}).then(onGetCatalog);
@ -82,7 +87,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.serviceCatalog.ifTypeEnabled
* @name ifTypeEnabled
* @description
* Checks if the desired service is enabled. If it is enabled, use the
* promise returned to execute the desired function. If it is not enabled,
@ -100,6 +105,7 @@
```js
serviceCatalog.ifTypeEnabled('network').then(getNetworks, doSomethingElse);
```
* @returns {promise} A promise that resolves if true, rejects with error
*/
function ifTypeEnabled(desiredType) {
var deferred = $q.defer();

View File

@ -28,7 +28,9 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.settings
* @name settingsService
* @param {Object} $q
* @param {Object} apiService
* @description
* Provides utilities to the cached settings data. This helps
* with asynchronous data loading.
@ -43,6 +45,7 @@
* particular page or modal. Making this a service allows it to be injected
* and used transparently where needed without making every single use of it
* pass it through as an argument.
* @returns {Object} The service
*/
function settingsService($q, apiService) {
@ -57,11 +60,12 @@
///////////////
/**
* @name horizon.app.core.openstack-service-api.config.getSettings
* @name getSettings
* @param {boolean} suppressError
* @description
* Gets all the allowed settings
*
* Returns an object with settings.
* @returns {Object} An object with settings
*/
function getSettings(suppressError) {
@ -85,7 +89,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.settings.getSetting
* @name getSetting
* @description
* This retrieves a specific setting.
*
@ -120,6 +124,7 @@
settingsService.getSetting('OPENSTACK_HYPERVISOR_FEATURES.can_set_mount_point')
.then(doSomething);
```
* @returns {promise} The setting as a promise
*/
function getSetting(path, defaultSetting) {
var deferred = $q.defer();
@ -153,7 +158,7 @@
}
/**
* @name horizon.app.core.openstack-service-api.settings.ifEnabled
* @name ifEnabled
* @description
* Checks if the desired setting is enabled. This returns a promise.
* If the setting is enabled, the promise will be resolved.
@ -236,6 +241,7 @@
settingsService.ifEnabled('OPENSTACK_API_VERSIONS.volume', 2, 1)
.then(doSomethingIfVersion2, doSomethingElse);
```
* @return {promise} A promise resolving if true, rejecting with error
*/
function ifEnabled(setting, expected, defaultSetting) {
var deferred = $q.defer();

View File

@ -27,8 +27,11 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.swift
* @name swiftAPI
* @param {Object} apiService
* @param {Object} toastService
* @description Provides direct pass through to Swift with NO abstraction.
* @returns {Object} The service
*/
function swiftAPI(apiService, toastService) {
var service = {
@ -62,10 +65,13 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.getObjectURL
* @name getObjectURL
* @param {Object} container - A container
* @param {Object} object - The object to be encoded
* @param {string} type - String representation of the type
* @description
* Calculate the download URL for an object.
*
* @returns {string} A URL that represents the given object
*/
function getObjectURL(container, object, type) {
var urlType = type || 'object';
@ -74,12 +80,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.getInfo
* @name getInfo
* @description
* Lists the activated capabilities for this version of the OpenStack
* Object Storage API.
*
* The result is an object passed through from the Swift /info/ call.
* @returns {Object} The result of the object passed to the Swift /info/ call.
*
*/
function getInfo() {
@ -90,11 +96,11 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.getContainers
* @name getContainers
* @description
* Get the list of containers for this account
*
* The result is an object with 'items' and 'has_more' flag.
* @returns {Object} An object with 'items' and 'has_more' flag.
*
*/
function getContainers() {
@ -105,11 +111,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.getContainer
* @name getContainer
* @param {Object} container - The container
* @description
* Get the container's detailed metadata
*
* The result is an object with the metadata fields.
* @returns {Object} An object with the metadata fields.
*
*/
function getContainer(container) {
@ -120,9 +127,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.createContainer
* @name createContainer
* @param {Object} container - The container
* @param {boolean} isPublic - Whether the container should be public
* @description
* Creates the named container with the is_public flag set to isPublic.
* @returns {Object} The result of the creation call
*
*/
function createContainer(container, isPublic) {
@ -142,9 +152,11 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.deleteContainer
* @name deleteContainer
* @param {Object} container - The container to delete
* @description
* Delete the named container.
* @returns {Object} The result of the delete call
*
*/
function deleteContainer(container) {
@ -155,9 +167,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.setContainerAccess
* @name setContainerAccess
* @param {Object} container - The container
* @param {boolean} isPublic - Whether the container should be public
* @description
* Set the container's is_public flag.
* @returns {Object} The result of the access call
*
*/
function setContainerAccess(container, isPublic) {
@ -170,13 +185,16 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.getObjects
* @name getObjects
* @param {Object} container - The container
* @param {Object} params - The parameters to pass to the call
* @description
* Get a listing of the objects in the container, optionally
* limited to a specific folder.
*
* Use the params value "path" to specify a folder prefix to limit
* the fetch to a pseudo-folder.
* @returns {Object} The result of the API call
*
*/
function getObjects(container, params) {
@ -193,10 +211,14 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.uploadObject
* @name uploadObject
* @param {Object} container - The container
* @param {string} objectName - The new object's name
* @param {Object} file - File data
* @description
* Add a file to the specified container with the given objectName (which
* may include pseudo-folder path), the mimetype and raw file data.
* @returns {Object} The result of the API call
*
*/
function uploadObject(container, objectName, file) {
@ -207,7 +229,7 @@
fd,
{
headers: {
'Content-Type': undefined
'Content-Type': ''
}
}
)
@ -217,9 +239,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.deleteObject
* @name deleteObject
* @param {Object} container - The container
* @param {string} objectName - The name of the object to delete
* @description
* Delete an object (or pseudo-folder).
* @returns {Object} The result of the API call
*
*/
function deleteObject(container, objectName) {
@ -238,9 +263,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.getObjectDetails
* @name getObjectDetails
* @param {Object} container - The container
* @param {string} objectName - The name of the object to get info about
* @description
* Get the metadata for an object.
* @returns {Object} The result of the API call
*
*/
function getObjectDetails(container, objectName) {
@ -253,9 +281,12 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.createFolder
* @name createFolder
* @param {Object} container - The container
* @param {string} folderName - The new folder name
* @description
* Create a pseudo-folder.
* @returns {Object} The result of the API call
*
*/
function createFolder(container, folderName) {
@ -269,9 +300,14 @@
}
/**
* @name horizon.app.core.openstack-service-api.swift.copyObject
* @name copyObject
* @param {Object} container - The original container
* @param {string} objectName - The original object's name
* @param {Object} destContainer - The destination container
* @param {string} destName - The destination object's name
* @description
* Copy an object.
* @returns {Object} The result of the API call
*
*/
function copyObject(container, objectName, destContainer, destName) {

View File

@ -124,7 +124,7 @@
call_args: [
'/api/swift/containers/spam/object/ham',
fakeFormData,
{headers: {'Content-Type': undefined}}
{headers: {'Content-Type': ''}}
],
error: 'Unable to upload the object.',
testInput: [ 'spam', 'ham', 'some junk' ]

View File

@ -28,7 +28,10 @@
/**
* @ngdoc service
* @name horizon.app.core.openstack-service-api.userSession
* @name userSession
* @param {Object} $cacheFactory
* @param {Object} $q
* @param {Object} keystoneAPI
* @description
* Provides cached access to the user session. The cache may be reset
* at any time by accessing the cache and calling removeAll, which means
@ -46,6 +49,7 @@
* particular page or modal. Making this a service allows it to be injected
* and used transparently where needed without making every single use of it
* pass it through as an argument.
* @returns {Object} The service
*/
function userSession($cacheFactory, $q, keystoneAPI) {