ldap.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. 'use strict';
  19. angular.module('ambariAdminConsole')
  20. .factory('LDAP', ['$http', '$q', 'Settings', function($http, $q, Settings) {
  21. return {
  22. get: function() {
  23. return $http({
  24. method: 'GET',
  25. url: '/api/v1/controllers/ldap'
  26. });
  27. },
  28. sync: function(groupsList, usersList) {
  29. groupsList = Array.isArray(groupsList) ? groupsList : [];
  30. usersList = Array.isArray(usersList) ? usersList : [];
  31. return $http({
  32. method: 'PUT',
  33. url: Settings.baseUrl + '/controllers/ldap',
  34. data:[{
  35. LDAP:{
  36. "synced_groups": groupsList.join(','),
  37. "synced_users": usersList.join(',')
  38. }
  39. }]
  40. });
  41. },
  42. syncResource: function(resourceType, items) {
  43. var items = items.map(function(item) {
  44. var name = 'LDAP/synced_' + resourceType;
  45. var obj = {};
  46. obj['LDAP/synced_' + resourceType] = item;
  47. return obj;
  48. });
  49. return $http({
  50. method: 'POST',
  51. url: '/api/v1/controllers/ldap',
  52. data: items
  53. });
  54. }
  55. };
  56. }]);