2015-01-30 17:25:32 +00:00
|
|
|
/*
|
|
|
|
Copyright 2015 IBM Corp.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
2015-06-08 15:43:29 +00:00
|
|
|
angular
|
|
|
|
.module('horizon.openstack-service-api')
|
|
|
|
.service('horizon.openstack-service-api.cinder', CinderAPI);
|
|
|
|
|
|
|
|
CinderAPI.$inject = ['horizon.framework.util.http.service',
|
|
|
|
'horizon.framework.widgets.toast.service'];
|
|
|
|
|
2015-01-30 17:25:32 +00:00
|
|
|
/**
|
|
|
|
* @ngdoc service
|
2015-06-08 15:43:29 +00:00
|
|
|
* @name horizon.openstack-service-api.cinder
|
2015-01-30 17:25:32 +00:00
|
|
|
* @description Provides direct access to Cinder APIs.
|
|
|
|
*/
|
2015-04-14 21:52:17 +00:00
|
|
|
function CinderAPI(apiService, toastService) {
|
2015-01-30 17:25:32 +00:00
|
|
|
|
|
|
|
// Volumes
|
|
|
|
|
|
|
|
/**
|
2015-06-08 15:43:29 +00:00
|
|
|
* @name horizon.openstack-service-api.cinder.getVolumes
|
2015-01-30 17:25:32 +00:00
|
|
|
* @description
|
|
|
|
* Get a list of volumes.
|
|
|
|
*
|
|
|
|
* The listing result is an object with property "items." Each item is
|
|
|
|
* a volume.
|
|
|
|
*
|
|
|
|
* @param {Object} params
|
|
|
|
* Query parameters. Optional.
|
|
|
|
*
|
|
|
|
* @param {string} param.search_opts
|
|
|
|
* Filters to pass through the API.
|
|
|
|
* For example, "status": "available" will show all available volumes.
|
|
|
|
*/
|
|
|
|
this.getVolumes = function(params) {
|
|
|
|
var config = (params) ? {'params': params} : {};
|
2015-02-28 07:25:28 +00:00
|
|
|
return apiService.get('/api/cinder/volumes/', config)
|
2015-01-30 17:25:32 +00:00
|
|
|
.error(function () {
|
2015-04-28 14:58:02 +00:00
|
|
|
toastService.add('error', gettext('Unable to retrieve the volumes.'));
|
2015-01-30 17:25:32 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Volume Snapshots
|
|
|
|
|
|
|
|
/**
|
2015-06-08 15:43:29 +00:00
|
|
|
* @name horizon.openstack-service-api.cinder.getVolumeSnapshots
|
2015-01-30 17:25:32 +00:00
|
|
|
* @description
|
|
|
|
* Get a list of volume snapshots.
|
|
|
|
*
|
|
|
|
* The listing result is an object with property "items." Each item is
|
|
|
|
* a volume snapshot.
|
|
|
|
*
|
|
|
|
* @param {Object} params
|
|
|
|
* Query parameters. Optional.
|
|
|
|
*
|
|
|
|
* @param {string} param.search_opts
|
|
|
|
* Filters to pass through the API.
|
|
|
|
* For example, "status": "available" will show all available volume
|
|
|
|
* snapshots.
|
|
|
|
*/
|
|
|
|
this.getVolumeSnapshots = function(params) {
|
|
|
|
var config = (params) ? {'params': params} : {};
|
2015-02-28 07:25:28 +00:00
|
|
|
return apiService.get('/api/cinder/volumesnapshots/', config)
|
2015-01-30 17:25:32 +00:00
|
|
|
.error(function () {
|
2015-04-14 21:52:17 +00:00
|
|
|
toastService.add('error',
|
2015-04-28 14:58:02 +00:00
|
|
|
gettext('Unable to retrieve the volume snapshots.'));
|
2015-01-30 17:25:32 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}());
|