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

View File

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

View File

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

View File

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

View File

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

View File

@ -72,6 +72,7 @@
* with the class of 'download-iframes' is present. * with the class of 'download-iframes' is present.
* *
* @param {string} name The desired name for the key pair * @param {string} name The desired name for the key pair
* @returns {promise} A promise resolving if true, rejecting with error
*/ */
function createAndDownloadKeypair(name) { function createAndDownloadKeypair(name) {
addDOMResource(name); addDOMResource(name);
@ -87,6 +88,7 @@
* the appropriate URL for the API to create/download the new key pair. * the appropriate URL for the API to create/download the new key pair.
* *
* @param {string} keypairName The desired name for the key pair * @param {string} keypairName The desired name for the key pair
* @returns {undefined} Returns nothing
*/ */
function addDOMResource(keypairName) { function addDOMResource(keypairName) {
var url = novaAPI.getCreateKeypairUrl(keypairName); var url = novaAPI.getCreateKeypairUrl(keypairName);
@ -113,6 +115,7 @@
* period, the promise is rejected. * period, the promise is rejected.
* *
* @param {string} name The name for the key pair * @param {string} name The name for the key pair
* @returns {promise} A promise resolving if true, rejecting with error
*/ */
function verifyCreatedPromise(name) { function verifyCreatedPromise(name) {
return $q(function doesKeypairExistPromise(resolve, reject) { 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 * @description
* Gets the current User Session Information * Gets the current User Session Information
* @example * @example
@ -126,6 +127,7 @@
* "user_domain_name": "Default", * "user_domain_name": "Default",
* "username": "admin" * "username": "admin"
* } * }
* @returns {Object} The result of the API call
*/ */
function getCurrentUserSession(config) { function getCurrentUserSession(config) {
return apiService.get('/api/keystone/user-session/', 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 * @description
* Returns the service catalog. * Returns the service catalog.
* @param {Object} config * @param {Object} config
* See $http config object parameters. * See $http config object parameters.
* @returns {Object} The result of the API call
*/ */
function serviceCatalog(config) { function serviceCatalog(config) {
return apiService.get('/api/keystone/svc-catalog/', config) return apiService.get('/api/keystone/svc-catalog/', config)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,8 +27,11 @@
/** /**
* @ngdoc service * @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. * @description Provides direct pass through to Swift with NO abstraction.
* @returns {Object} The service
*/ */
function swiftAPI(apiService, toastService) { function swiftAPI(apiService, toastService) {
var service = { 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 * @description
* Calculate the download URL for an object. * Calculate the download URL for an object.
* * @returns {string} A URL that represents the given object
*/ */
function getObjectURL(container, object, type) { function getObjectURL(container, object, type) {
var urlType = type || 'object'; var urlType = type || 'object';
@ -74,12 +80,12 @@
} }
/** /**
* @name horizon.app.core.openstack-service-api.swift.getInfo * @name getInfo
* @description * @description
* Lists the activated capabilities for this version of the OpenStack * Lists the activated capabilities for this version of the OpenStack
* Object Storage API. * 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() { function getInfo() {
@ -90,11 +96,11 @@
} }
/** /**
* @name horizon.app.core.openstack-service-api.swift.getContainers * @name getContainers
* @description * @description
* Get the list of containers for this account * 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() { function getContainers() {
@ -105,11 +111,12 @@
} }
/** /**
* @name horizon.app.core.openstack-service-api.swift.getContainer * @name getContainer
* @param {Object} container - The container
* @description * @description
* Get the container's detailed metadata * 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) { 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 * @description
* Creates the named container with the is_public flag set to isPublic. * Creates the named container with the is_public flag set to isPublic.
* @returns {Object} The result of the creation call
* *
*/ */
function createContainer(container, isPublic) { 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 * @description
* Delete the named container. * Delete the named container.
* @returns {Object} The result of the delete call
* *
*/ */
function deleteContainer(container) { 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 * @description
* Set the container's is_public flag. * Set the container's is_public flag.
* @returns {Object} The result of the access call
* *
*/ */
function setContainerAccess(container, isPublic) { 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 * @description
* Get a listing of the objects in the container, optionally * Get a listing of the objects in the container, optionally
* limited to a specific folder. * limited to a specific folder.
* *
* Use the params value "path" to specify a folder prefix to limit * Use the params value "path" to specify a folder prefix to limit
* the fetch to a pseudo-folder. * the fetch to a pseudo-folder.
* @returns {Object} The result of the API call
* *
*/ */
function getObjects(container, params) { 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 * @description
* Add a file to the specified container with the given objectName (which * Add a file to the specified container with the given objectName (which
* may include pseudo-folder path), the mimetype and raw file data. * may include pseudo-folder path), the mimetype and raw file data.
* @returns {Object} The result of the API call
* *
*/ */
function uploadObject(container, objectName, file) { function uploadObject(container, objectName, file) {
@ -207,7 +229,7 @@
fd, fd,
{ {
headers: { 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 * @description
* Delete an object (or pseudo-folder). * Delete an object (or pseudo-folder).
* @returns {Object} The result of the API call
* *
*/ */
function deleteObject(container, objectName) { 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 * @description
* Get the metadata for an object. * Get the metadata for an object.
* @returns {Object} The result of the API call
* *
*/ */
function getObjectDetails(container, objectName) { 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 * @description
* Create a pseudo-folder. * Create a pseudo-folder.
* @returns {Object} The result of the API call
* *
*/ */
function createFolder(container, folderName) { 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 * @description
* Copy an object. * Copy an object.
* @returns {Object} The result of the API call
* *
*/ */
function copyObject(container, objectName, destContainer, destName) { function copyObject(container, objectName, destContainer, destName) {

View File

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

View File

@ -28,7 +28,10 @@
/** /**
* @ngdoc service * @ngdoc service
* @name horizon.app.core.openstack-service-api.userSession * @name userSession
* @param {Object} $cacheFactory
* @param {Object} $q
* @param {Object} keystoneAPI
* @description * @description
* Provides cached access to the user session. The cache may be reset * Provides cached access to the user session. The cache may be reset
* at any time by accessing the cache and calling removeAll, which means * 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 * 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 * and used transparently where needed without making every single use of it
* pass it through as an argument. * pass it through as an argument.
* @returns {Object} The service
*/ */
function userSession($cacheFactory, $q, keystoneAPI) { function userSession($cacheFactory, $q, keystoneAPI) {