ScriptsService.js revision 30ad4487f491cce61c10639362ccf67a3e4bf0a0
1043N/A/**
1043N/A * The contents of this file are subject to the terms of the Common Development and
1043N/A * Distribution License (the License). You may not use this file except in compliance with the
5359N/A * License.
1043N/A *
1043N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
1043N/A * specific language governing permission and limitations under the License.
1043N/A *
1043N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
1043N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
1043N/A * Header, with the fields enclosed by brackets [] replaced by your own identifying
1043N/A * information: "Portions copyright [year] [name of copyright owner]".
1043N/A *
1043N/A * Copyright 2016 ForgeRock AS.
1043N/A */
1043N/A
1043N/A/**
1043N/A * @module org/forgerock/openam/ui/admin/services/global/ScriptsService
1043N/A */
1043N/Adefine([
2362N/A "lodash",
2362N/A "org/forgerock/commons/ui/common/main/AbstractDelegate",
2362N/A "org/forgerock/commons/ui/common/util/Constants",
1043N/A "org/forgerock/openam/ui/admin/services/SMSServiceUtils",
1043N/A "org/forgerock/openam/ui/common/util/Promise",
1043N/A "org/forgerock/openam/ui/common/util/RealmHelper"
1043N/A], (_, AbstractDelegate, Constants, SMSServiceUtils, Promise, RealmHelper) => {
1043N/A const obj = new AbstractDelegate(`${Constants.host}/${Constants.context}/json/global-config/services/scripting`);
1043N/A
1043N/A obj.scripts = {
1043N/A /**
1043N/A * Gets all script's contexts.
1043N/A * @returns {Promise.<Object>} Service promise
1043N/A */
1043N/A getAllContexts () {
1043N/A return obj.serviceCall({
1043N/A url: RealmHelper.decorateURLWithOverrideRealm("/contexts?_queryFilter=true"),
1043N/A headers: { "Accept-API-Version": "protocol=1.0,resource=1.0" }
1043N/A });
1043N/A },
1043N/A
1043N/A /**
1043N/A * Gets a default global script's context.
1043N/A * @returns {Promise.<Object>} Service promise
1043N/A */
1043N/A getDefaultGlobalContext () {
1043N/A return obj.serviceCall({
1043N/A url: RealmHelper.decorateURLWithOverrideRealm(""),
1043N/A headers: { "Accept-API-Version": "protocol=1.0,resource=1.0" }
1043N/A });
1043N/A },
1043N/A
1043N/A /**
1043N/A * Gets a script's schema.
1043N/A * @returns {Promise.<Object>} Service promise
1043N/A */
1043N/A getSchema () {
1043N/A return obj.serviceCall({
1043N/A url: RealmHelper.decorateURLWithOverrideRealm("?_action=schema"),
1043N/A headers: { "Accept-API-Version": "protocol=1.0,resource=1.0" },
5359N/A type: "POST"
5359N/A });
5359N/A },
5359N/A
4638N/A /**
4638N/A * Gets a script context's schema.
4638N/A * @returns {Promise.<Object>} Service promise
4638N/A */
1043N/A getContextSchema () {
1043N/A return obj.serviceCall({
1043N/A url: RealmHelper.decorateURLWithOverrideRealm("/contexts?_action=schema"),
1043N/A headers: { "Accept-API-Version": "protocol=1.0,resource=1.0" },
1043N/A type: "POST"
1043N/A });
1043N/A }
1043N/A };
1043N/A
1043N/A return obj;
1043N/A});
1043N/A