/*-
 * ============LICENSE_START=======================================================
 * ONAP CLAMP
 * ================================================================================
 * Copyright (C) 2019 AT&T Intellectual Property. All rights
 *                             reserved.
 * ================================================================================
 * 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.
 * ============LICENSE_END============================================
 * ===================================================================
 *
 */

export default class LoopActionService{

	static performAction(cl_name, uiAction) {
		console.log("LoopActionService perform action: " + uiAction + " closedloopName=" + cl_name);
		const svcAction = uiAction.toLowerCase();
 		return fetch("/restservices/clds/v2/loop/" + svcAction + "/" + cl_name, {
 				method: 'PUT',
 				credentials: 'same-origin'
 			})
 		.then(function (response) {
 			if (response.ok) {
 				return response.json();
 			} else {
 				return Promise.reject("Perform action failed with code:" + response.status);
 			}
 		})
 		.then(function (data) {
			alert("Action Successful: " + uiAction);
 			return data;
 		})
 		.catch(function(error) {
 			console.log("Action Failure: " + uiAction);
 			return Promise.reject(error);
 		});
 	}


	static refreshStatus(cl_name) {
		console.log("Refresh the status for closedloopName=" + cl_name);

		return fetch("/restservices/clds/v2/loop/getstatus/" + cl_name, {
			method: 'GET',
			credentials: 'same-origin'
		})
		.then(function (response) {
			if (response.ok) {
				return response.json();
			} else {
				return Promise.reject("Refresh status failed with code:" + response.status);
			}
		})
		.then(function (data) {
			console.info ("Refresh status Successful");
			return data;
		})
		.catch(function(error) {
			console.info ("Refresh status failed:", error);
			return Promise.reject(error);
		});
 	}
}
