/*-
 * ============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);
		});
 	}
}
