2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 import NetworkCalls from './networking/NetworkCalls.js';
31 } from './networking/NetworkConstants.js';
33 createEditEntityAttributeRequestObject
34 } from './networking/NetworkUtils.js';
36 setAttributesActionTypes,
37 EDIT_ENTITY_ATTRIBUTES_URL,
38 RESPONSE_CODE_SUCCESS,
39 RESPONSE_CODE_NOT_AUTHORIZED,
40 RESPONSE_MESSAGE_SUCCESS,
41 RESPONSE_MESSAGE_NOT_AUTHORIZED,
42 RESPONSE_MESSAGE_FAILURE,
43 RESPONSE_MESSAGE_NETWORK_ERROR
44 } from './EditAttributeConstants.js';
46 function errorReturnedEvent(errorMsg) {
48 type: setAttributesActionTypes.SET_ATTRIBUTE_ERROR,
49 data: {errorMsg: errorMsg}
53 function successReturnedEvent() {
55 type: setAttributesActionTypes.SET_ATTRIBUTE_SUCCESS,
56 data: {successMsg: RESPONSE_MESSAGE_SUCCESS}
60 function clearFeedbackMessageEvent() {
62 type: setAttributesActionTypes.CLEAR_FEEDBACK_MESSAGE,
67 export function clearFeebackMessage() {
69 dispatch(clearFeedbackMessageEvent());
73 export function requestEditEntityAttributes(entityURI, entityAttributes) {
75 let postBody = JSON.stringify(
76 createEditEntityAttributeRequestObject(entityURI, entityAttributes));
78 return NetworkCalls.fetchRequest(EDIT_ENTITY_ATTRIBUTES_URL,
79 CREDENTIALS, POST, BACKEND_POST_HEADER, postBody).then(
82 if (responseJson.resultCode === RESPONSE_CODE_SUCCESS) {
83 dispatch(successReturnedEvent());
84 } else if (responseJson.resultCode === RESPONSE_CODE_NOT_AUTHORIZED) {
85 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NOT_AUTHORIZED));
87 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_FAILURE));
93 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NETWORK_ERROR));