'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var core = require('@al/core');

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

function __awaiter(thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

class AlPoliciesClientInstance {
    /* istanbul ignore next */
    constructor() {
        this.serviceVersion = 'v1';
        this.serviceName = 'policies';
    }
    /**
     * Returns the policy matching account_id and policy_id specified
     */
    getPolicy(accountId, policyId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                version: this.serviceVersion,
                path: `/policies/${policyId}`,
            });
        });
    }
    /**
     * Lists policies belonging to a particular account
     */
    listPolicies(accountId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                version: this.serviceVersion,
                path: '/policies',
            });
        });
    }
}

/**
 * These two functions perform opposite operations.
 * Policy name is transform to  node flavor once the whitespaces have bee replace with '-'.
 */
function parsePolicyName(policyName) {
    return policyName.toLowerCase().replace(/\s/g, '-');
}
function parseNodeFlavor(flavorValue) {
    return flavorValue.replace("-", " ");
}
/**
 * Returns the fist 'policy.byParam 'that matches 'value'.
 * The match criteria is not case sensitive.
 */
function findPolicy(policies, byParam, value) {
    let expression;
    if (byParam === 'name') {
        const parsedFlavorValue = parseNodeFlavor(value);
        expression = new RegExp(parsedFlavorValue, "i");
    }
    else {
        expression = new RegExp(value, "i");
    }
    return policies.find(policy => !!policy[byParam].match(expression));
}

/* tslint:disable:variable-name */
const AlPoliciesClient = core.AlGlobalizer.instantiate('al.policies', () => new AlPoliciesClientInstance());

class AlFimClientInstance {
    constructor() {
        this.serviceName = 'fim_config';
        this.serviceVersion = 'v1';
    }
    /**
    * Lists all fim excluded or monitored path configuration objects
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-MonitoredPaths-ListConfigurations
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-ExcludedPaths-ListConfigurations
    */
    getAllConfigurations(pathType, accountId, deploymentId) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/deployments/${deploymentId}/${pathType}`,
            });
        });
    }
    /**
    *  Gets a single fim excluded or monitored path configuration object
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-MonitoredPaths-GetConfiguration
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-ExcludedPaths-GetConfiguration
    */
    getConfiguration(pathType, accountId, deploymentId, configurationId) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/deployments/${deploymentId}/${pathType}/${configurationId}`,
            });
        });
    }
    /**
    *  creates a fim excluded or monitored path configuration object
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-MonitoredPaths-CreateConfiguration
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-ExcludedPaths-CreateConfiguration
    */
    createConfiguration(pathType, accountId, deploymentId, payload) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield core.AlDefaultClient.post({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/deployments/${deploymentId}/${pathType}`,
                data: payload
            });
        });
    }
    /**
    *  updates a fim excluded or monitored path configuration object
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-MonitoredPaths-UpdateConfiguration
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-ExcludedPaths-CreateConfiguration
    */
    updateConfiguration(pathType, accountId, deploymentId, configurationId, payload) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield core.AlDefaultClient.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/deployments/${deploymentId}/${pathType}/${configurationId}`,
                data: payload
            });
        });
    }
    /**
   *  Deletes a fim excluded or monitored path configuration object
   *  @remarks
   *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-MonitoredPaths-DeleteConfiguration
   *  @remarks
   *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-ExcludedPaths-DeleteConfiguration
   */
    deleteConfiguration(pathType, accountId, deploymentId, configurationId) {
        return __awaiter(this, void 0, void 0, function* () {
            yield core.AlDefaultClient.delete({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/deployments/${deploymentId}/${pathType}/${configurationId}`,
            });
        });
    }
    /**
    *  Gets the configuration summary report
    *  @remarks
    *  https://console.account.product.dev.alertlogic.com/users/api/fim_config/index.html#api-Reports-GetSummary
    */
    getConfigurationsSummary(accountId) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: '/reports/summary',
            });
        });
    }
}

/* eslint-disable-next-line */
const nixRegex = new RegExp(/^(?:\/[^\*\|\?]+)*\/([^\*\|\?]*\.?[^\*\|\?]+?)?$/);
const windowsRegistryRegex = new RegExp(/^((?:.*)\\)(.*)$/);
/* eslint-disable-next-line */
const windowsDirectoryRegex = new RegExp(/^(?:[a-zA-Z]\:)(?:\\[^\*\?\|]*)*\\?([^\*\?\|]*\.?[^\*\?\|]*?)$/);
function getFullPath(config) {
    try {
        const suffix = config.pattern ? config.pattern : "";
        const separator = config.type === 'nix_dir' ? "/" : "\\";
        if (config.base.slice(-1) === separator) {
            return suffix === '*' || suffix === '**' ? `${config.base}` : `${config.base}${suffix}`;
        }
        return suffix === '*' || suffix === '**' ? `${config.base}${separator}` : `${config.base}${separator}${suffix}`;
    }
    catch (error) {
        console.error("getFullPath -> unexpected error ", error);
        return '';
    }
}

/* tslint:disable:variable-name */
const AlFimClient = core.AlGlobalizer.instantiate("AlFimClient", () => new AlFimClientInstance());

class ThemisClient {
    constructor() {
        this.serviceName = 'themis';
    }
    getRole(accountId, platformType, roleType, roleVersion) {
        return __awaiter(this, void 0, void 0, function* () {
            const role = yield core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: 'v1',
                service_name: this.serviceName,
                account_id: accountId,
                path: `/roles/${platformType}/${roleType}/${roleVersion}`,
            });
            return role;
        });
    }
    getRoles(accountId) {
        return __awaiter(this, void 0, void 0, function* () {
            const roles = yield core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: 'v1',
                service_name: this.serviceName,
                account_id: accountId,
                path: '/roles',
            });
            return roles;
        });
    }
    validateRoleCredentials(accountId, awsRole) {
        return __awaiter(this, void 0, void 0, function* () {
            const validate = yield core.AlDefaultClient.post({
                service_stack: core.AlLocation.InsightAPI,
                version: 'v1',
                service_name: this.serviceName,
                account_id: accountId,
                path: `/validate/${awsRole.platform_type}/${awsRole.role_type}`,
            });
            return validate;
        });
    }
}
const themisClient = new ThemisClient();

class AlWatchlistClientInstance {
    /* istanbul ignore next */
    constructor() {
        this.serviceName = 'watchlist';
        this.serviceVersion = 'v1';
    }
    add(accountId, deploymentId, userId, assetKey) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const rawResponse = yield core.AlDefaultClient.post({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${userId}`,
                data: {
                    key: assetKey,
                    environment_id: deploymentId
                }
            });
            return ((_a = rawResponse === null || rawResponse === void 0 ? void 0 : rawResponse.watchlist) !== null && _a !== void 0 ? _a : {});
        });
    }
    remove(accountId, userId, assetKey) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.delete({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${userId}/${assetKey}`
            });
        });
    }
}

/* tslint:disable:variable-name */
const AlWatchlistClient = core.AlGlobalizer.instantiate("AlWatchlistClient", () => new AlWatchlistClientInstance());

class AlwsWhitelistClientInstance {
    /* istanbul ignore next */
    constructor() {
        this.serviceName = 'whitelist';
        this.serviceVersion = 'v1';
    }
    listTags(accountId, deploymentId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${deploymentId}`
            });
        });
    }
    addTag(accountId, deploymentId, tag) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.post({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                data: tag,
                path: `/${deploymentId}`
            });
        });
    }
    deleteTag(accountId, deploymentId, tag) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.delete({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                data: tag,
                path: `/${deploymentId}`
            });
        });
    }
}

/* tslint:disable:variable-name */
const AlWhitelistClient = core.AlGlobalizer.instantiate('al.whitelist', () => new AlwsWhitelistClientInstance());

class AlScanSchedulerClientInstanceV2 {
    constructor() {
        this.serviceName = 'scheduler';
    }
    /**
     *  Lists scan schedules that belong to a particular deployment
     */
    getScanSchedulesList(accountId, deploymentId, params = {}) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/schedules`,
                params: params
            });
        });
    }
    /**
     *  Create new Scan Schedule for a given deployment
     */
    createScanSchedule(accountId, deploymentId, schedule) {
        return __awaiter(this, void 0, void 0, function* () {
            const result = yield core.AlDefaultClient.post({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/schedules`,
                data: schedule,
            });
            if (!result.hasOwnProperty("id")) {
                throw new core.AlResponseValidationError(`Service returned unexpected result; missing 'id' property.`);
            }
            return result;
        });
    }
    /**
     *  Returns the scan schedule definition for a given id
     */
    getScanSchedule(accountId, deploymentId, scheduleId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/schedules/${scheduleId}`,
            });
        });
    }
    /**
     *  Deletes Selected Schedule
     */
    removeScanSchedule(accountId, deploymentId, scheduleId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.delete({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/schedules/${scheduleId}`
            });
        });
    }
    /**
     *   Updates a selected scan schedule
     */
    updateScanSchedule(accountId, deploymentId, scheduleId, schedule) {
        return __awaiter(this, void 0, void 0, function* () {
            const result = yield core.AlDefaultClient.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/schedules/${scheduleId}`,
                data: schedule
            });
            if (!result.hasOwnProperty("id")) {
                throw new core.AlResponseValidationError(`Service returned unexpected result; missing 'id' property.`);
            }
            return result;
        });
    }
    /**
     *  Get scan schedule summary by ID
     */
    getScanScheduleSummary(accountId, deploymentId, scheduleId, params = {}) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/schedules/${scheduleId}/summary`,
                params: params
            });
        });
    }
    /**
     *  Validates a list of supplied IP Addresses, checking for their correctness.
     *  This API always returns 200 OK status and provides the results of validation using two arrays with respective status (valid/invalid).
     *  IP Addresses that are present in the valid list can be subsequently used as applicable ScanScopeItems.
     */
    validateIp(accountId, deploymentId, ips, typeOfScan = 'vulnerability') {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.post({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/ip_validator/${typeOfScan}`,
                data: ips
            });
        });
    }
    /**
     *  Lists supported timezones that can be used in ScanWindow definition
     */
    getTimeZonesList() {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                path: `/timezones`
            });
        });
    }
    /**
     *  Expedites scan for all the scannable targets that are descendants of a given
     *  level of the topology (for example all hosts belonging to a given subnet)
     *
     *  @force param: Allows to override the exclusion rules applied to selected targets.
     *                Otherwise exclusion rules take precedence over expedited scan.
     */
    scanNow(accountId, deploymentId, scanScopeItem, params = { force: false }) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/scan`,
                data: scanScopeItem,
                params: params
            });
        });
    }
    /**
     * Stops scans for selected list of assets
     * All scan jobs currently running against targets that are within the scope defined by the ScanScopeItem object, will be terminated.
     * Targets will not be re-enqueued until the next scan SLA period defined by scan_frequency parameter of a schedule that contains each of the targets.
     * @param accountId
     * @param deploymentId
     */
    stopScanAssets(accountId, deploymentId, scanScopeItem) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/stop`,
                data: scanScopeItem
            });
        });
    }
    /**
     * Stops a selected scan schedule
     * All scan jobs currently running against targets that are within the scope defined by the selected schedule, will be terminated.
     * Targets will not be re-enqueued until the next scan SLA period defined by scan_frequency parameter of the schedule.
     * @param accountId
     * @param deploymentId
     * @param scanScheduleId
     */
    stopScanSchedule(accountId, deploymentId, scanScheduleId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: 2,
                account_id: accountId,
                path: `/${deploymentId}/schedules/${scanScheduleId}/stop`
            });
        });
    }
}

exports.ScanOptionPort = void 0;
(function (ScanOptionPort) {
    ScanOptionPort.protoEnum = {
        T: 't',
        U: 'u',
        Tu: 'tu'
    };
})(exports.ScanOptionPort || (exports.ScanOptionPort = {}));

exports.ScanOptionPortWildcard = void 0;
(function (ScanOptionPortWildcard) {
    ScanOptionPortWildcard.valueEnum = {
        Common: 'common',
        Star: '*',
        TypicallyVulnerable: 'typically_vulnerable',
        All: 'all'
    };
})(exports.ScanOptionPortWildcard || (exports.ScanOptionPortWildcard = {}));

exports.AlScanScopeItem = void 0;
(function (AlScanScopeItem) {
    AlScanScopeItem.typeEnum = {
        Asset: 'asset',
        Cidr: 'cidr',
        IpAddress: 'ip_address',
        IpRange: 'ip_range',
        Tag: 'tag'
    };
})(exports.AlScanScopeItem || (exports.AlScanScopeItem = {}));

exports.AlScanScopeItemAsset = void 0;
(function (AlScanScopeItemAsset) {
    AlScanScopeItemAsset.assetTypeEnum = {
        Deployment: 'deployment',
        Region: 'region',
        Network: 'network',
        Vpc: 'vpc',
        Subnet: 'subnet',
        Host: 'host',
        ExternalIp: 'external-ip',
        ExternalDnsName: 'external-dns-name'
    };
    AlScanScopeItemAsset.typeEnum = {
        Asset: 'asset'
    };
})(exports.AlScanScopeItemAsset || (exports.AlScanScopeItemAsset = {}));

exports.AlScanScopeItemCIDR = void 0;
(function (AlScanScopeItemCIDR) {
    AlScanScopeItemCIDR.typeEnum = {
        Cidr: 'cidr'
    };
})(exports.AlScanScopeItemCIDR || (exports.AlScanScopeItemCIDR = {}));

exports.AlScanScopeItemIPAddress = void 0;
(function (AlScanScopeItemIPAddress) {
    AlScanScopeItemIPAddress.typeEnum = {
        Address: 'ip_address'
    };
})(exports.AlScanScopeItemIPAddress || (exports.AlScanScopeItemIPAddress = {}));

exports.AlScanScopeItemIPRange = void 0;
(function (AlScanScopeItemIPRange) {
    AlScanScopeItemIPRange.typeEnum = {
        Range: 'ip_range'
    };
})(exports.AlScanScopeItemIPRange || (exports.AlScanScopeItemIPRange = {}));

exports.AlScanScopeItemTag = void 0;
(function (AlScanScopeItemTag) {
    AlScanScopeItemTag.typeEnum = {
        Tag: 'tag'
    };
})(exports.AlScanScopeItemTag || (exports.AlScanScopeItemTag = {}));

exports.AlScanWindow = void 0;
(function (AlScanWindow) {
    AlScanWindow.typeEnum = {
        DaysOfWeek: 'days_of_week',
        DaysOfMonth: 'days_of_month',
        WeeklyPeriod: 'weekly_period',
        MonthlyPeriod: 'monthly_period',
        SpecificDate: 'specific_date',
        Quarterly: 'quarterly',
        WeekdayOfMonth: 'weekday_of_month'
    };
})(exports.AlScanWindow || (exports.AlScanWindow = {}));

exports.AlScanWindowContinuousPeriodMonthly = void 0;
(function (AlScanWindowContinuousPeriodMonthly) {
    AlScanWindowContinuousPeriodMonthly.typeEnum = {
        Period: 'monthly_period'
    };
})(exports.AlScanWindowContinuousPeriodMonthly || (exports.AlScanWindowContinuousPeriodMonthly = {}));

exports.AlScanWindowContinuousPeriodWeekly = void 0;
(function (AlScanWindowContinuousPeriodWeekly) {
    AlScanWindowContinuousPeriodWeekly.typeEnum = {
        Period: 'weekly_period'
    };
})(exports.AlScanWindowContinuousPeriodWeekly || (exports.AlScanWindowContinuousPeriodWeekly = {}));

exports.AlScanWindowContinuousQuarterly = void 0;
(function (AlScanWindowContinuousQuarterly) {
    AlScanWindowContinuousQuarterly.typeEnum = {
        Quarterly: 'quarterly'
    };
})(exports.AlScanWindowContinuousQuarterly || (exports.AlScanWindowContinuousQuarterly = {}));

exports.AlScanWindowSelectedDaysOfMonth = void 0;
(function (AlScanWindowSelectedDaysOfMonth) {
    AlScanWindowSelectedDaysOfMonth.typeEnum = {
        Month: 'days_of_month'
    };
})(exports.AlScanWindowSelectedDaysOfMonth || (exports.AlScanWindowSelectedDaysOfMonth = {}));

exports.AlScanWindowSelectedDaysOfWeek = void 0;
(function (AlScanWindowSelectedDaysOfWeek) {
    AlScanWindowSelectedDaysOfWeek.typeEnum = {
        Week: 'days_of_week'
    };
})(exports.AlScanWindowSelectedDaysOfWeek || (exports.AlScanWindowSelectedDaysOfWeek = {}));

exports.AlScanWindowSelectedWeekdayOfMonth = void 0;
(function (AlScanWindowSelectedWeekdayOfMonth) {
    AlScanWindowSelectedWeekdayOfMonth.typeEnum = {
        Month: 'weekday_of_month'
    };
    AlScanWindowSelectedWeekdayOfMonth.dayOfWeekEnum = {
        NUMBER_1: 1,
        NUMBER_2: 2,
        NUMBER_3: 3,
        NUMBER_4: 4,
        NUMBER_5: 5,
        NUMBER_6: 6,
        NUMBER_7: 7
    };
    AlScanWindowSelectedWeekdayOfMonth.nthWeekEnum = {
        NUMBER_1: 1,
        NUMBER_2: 2,
        NUMBER_3: 3,
        NUMBER_4: 4
    };
})(exports.AlScanWindowSelectedWeekdayOfMonth || (exports.AlScanWindowSelectedWeekdayOfMonth = {}));

exports.AlScanWindowSpecificDate = void 0;
(function (AlScanWindowSpecificDate) {
    AlScanWindowSpecificDate.typeEnum = {
        Date: 'specific_date'
    };
})(exports.AlScanWindowSpecificDate || (exports.AlScanWindowSpecificDate = {}));

exports.AlScanSchedule = void 0;
(function (AlScanSchedule) {
    AlScanSchedule.typeOfScanEnum = {
        Vulnerability: 'vulnerability',
        External: 'external',
        Discovery: 'discovery',
        Abs: 'abs',
    };
    AlScanSchedule.scanFrequencyEnum = {
        Automatic: 'automatic',
        Daily: 'daily',
        Weekly: 'weekly',
        Fortnightly: 'fortnightly',
        Monthly: 'monthly',
        Quarterly: 'quarterly',
        Once: 'once',
    };
})(exports.AlScanSchedule || (exports.AlScanSchedule = {}));

exports.AlScanScheduleSummary = void 0;
(function (AlScanScheduleSummary) {
    AlScanScheduleSummary.statusEnum = {
        Disabled: 'disabled',
        Idle: 'idle',
        InProgress: 'in_progress',
        Stopped: 'stopped'
    };
})(exports.AlScanScheduleSummary || (exports.AlScanScheduleSummary = {}));

exports.AlTimeZone = void 0;
(function (AlTimeZone) {
    AlTimeZone.statusEnum = {
        Canonical: 'Canonical',
        Alias: 'Alias'
    };
})(exports.AlTimeZone || (exports.AlTimeZone = {}));

/* tslint:disable:variable-name */
const AlScanSchedulerClientV2 = core.AlGlobalizer.instantiate("AlScanSchedulerClientV2", () => new AlScanSchedulerClientInstanceV2());

class AlSchedulerClientInstance {
    /* istanbul ignore next */
    constructor() {
        this.serviceName = 'scheduler';
        this.serviceVersion = 1;
    }
    getScanStatusSummary(accountId, deploymentId, queryParams) {
        return __awaiter(this, void 0, void 0, function* () {
            const summary = yield core.AlDefaultClient.get({
                service_name: this.serviceName,
                account_id: accountId,
                path: `${deploymentId}/summary`,
                params: queryParams,
                version: 1
            });
            return summary;
        });
    }
    getScanTargets(accountId, deploymentId) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield core.AlDefaultClient.get({
                service_name: this.serviceName,
                account_id: accountId,
                path: `${deploymentId}/targets`,
                version: this.serviceVersion
            });
            return ((_a = response === null || response === void 0 ? void 0 : response.targets) !== null && _a !== void 0 ? _a : []);
        });
    }
    scanAsset(accountId, deploymentId, assetKey, force = false) {
        return __awaiter(this, void 0, void 0, function* () {
            return yield core.AlDefaultClient.put({
                service_name: this.serviceName,
                account_id: accountId,
                path: `${deploymentId}/scan`,
                params: { asset: assetKey, force: force },
                version: this.serviceVersion
            });
        });
    }
}

/* tslint:disable:variable-name */
const AlSchedulerClient = core.AlGlobalizer.instantiate('al.scheduler', () => new AlSchedulerClientInstance());

class AlApplicationsClientInstance {
    constructor() {
        this.serviceName = 'applications';
        this.serviceVersion = 'v1';
    }
    /**
     * Return the catalog of application definitions with their default log collection configuration
     * GET
     * /applications/v1/:account_id/applications
     * "https://api.product.dev.alertlogic.com/applications/v1/01000001/applications"
     *
     *  @param accountId AIMS Account ID
     *  @returns a promise with the applications list
     *
     *  @remarks
     *  https://console.product.dev.alertlogic.com/api/applications/#api-Applications-ListApplications
     */
    getAllApplications(accountId, queryParams) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: '/applications',
                params: queryParams
            });
        });
    }
    /**
     * Creates a new log collection rule. All omitted properties will be derived from the application definition.
     * POST
     * /applications/v1/:account_id/rules
     * "https://api.product.dev.alertlogic.com/applications/v1/01000001/rules"
     *
     * @param accountId AIMS Account ID
     * @param data The application log rule request body
     * @returns a promise with the subscriptions
     *
     * @remarks
     * https://console.product.dev.alertlogic.com/api/applications/#api-Rules-PostRules
     */
    addRule(accountId, data, deploymentId = null) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.post({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: deploymentId ? `/deployments/${deploymentId}/rules` : `/rules`,
                data: data
            });
        });
    }
    /**
     * Return the log collection rule
     * GET
     * /applications/v1/:account_id/rules/:rule_id
     * "https://api.product.dev.alertlogic.com/applications/v1/01000001/rules/0C51E404-4BB4-4228-B6B7-32B43029C76F"
     *
     * @param accountId AIMS Account ID
     * @param ruleId Rule identifier
     * @returns a promise with the log collection rule
     *
     * @remarks
     * https://console.product.dev.alertlogic.com/api/applications/#api-Rules-GetRule
     */
    getRule(accountId, ruleId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/rules/${ruleId}`
            });
        });
    }
    /**
     * Return the list of log collection rules
     * GET
     * /applications/v1/:account_id/rules
     * "https://api.product.dev.alertlogic.com/applications/v1/01000001/rules"
     *
     *  @param accountId AIMS Account ID
     *  @returns a promise with the rules list
     *
     *  @remarks
     *  https://console.product.dev.alertlogic.com/api/applications/#api-Rules-ListRules
     */
    getAllRules(accountId, queryParams, deploymentId = null) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: deploymentId ? `/deployments/${deploymentId}/rules` : `/rules`,
                params: queryParams
            });
        });
    }
    /**
     * Allows to delete a rule
     * DELETE
     * /applications/v1/:account_id/rules/:rule_id
     *
     * @param accountId The AIMS Account ID
     * @param ruleId The Rule identifier to delete
     * @returns just the status code
     *
     * @remarks
     * https://api.product.dev.alertlogic.com/applications/v1/01000001/rules/B37CEE84-6D27-4D0F-943C-F23937587574
     */
    deleteRule(accountId, ruleId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.delete({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/rules/${ruleId}`
            });
        });
    }
    /**
     * Update a Rule
     * PUT
     * /applications/v1/:account_id/rules/:rule_id
     *
     * @param notificationType The notification type as string
     * @param payload Notification type object
     * @param deploymentId deployment id (optional)
     * @returns a promise with the notification type that was updated
     *
     * @remarks
     * https://api.product.dev.alertlogic.com/applications/v1/01000001/rules/BD30F3F3-5D12-421A-B806-C65155C40CE1
     */
    updateRule(accountId, ruleId, payload, deploymentId = null) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: deploymentId ? `/deployments/${deploymentId}/rules/${ruleId}` : `/rules/${ruleId}`,
                data: payload
            });
        });
    }
    /**
     * Return the list of log collection rules for a deployment
     * GET
     * /applications/v1/:account_id/deployments/:deployment_id/rules
     * "https://api.product.dev.alertlogic.com/applications/v1/01000001/deployments/E78E4878-A96E-48BD-A27B-0EE56BEA1FE4/rules"
     *
     *  @param accountId AIMS Account ID
     *  @returns a promise with the rules list of a given deployment
     *
     *  @remarks
     *  https://console.product.dev.alertlogic.com/api/applications/#api-Rules-ListRulesDepl
     */
    getAllRulesByDeployment(accountId, deploymentId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/deployments/${deploymentId}/rules`,
            });
        });
    }
    /**
     * Deploys a collector with given parameters
     * POST
     * /applications/v1/:account_id/collectors
     * curl -X POST https://api.product.dev.alertlogic.com/applications/v1/01000001/collectors -d
     * {
     *      "name": "okta",
     *      "application_id": "16",
     *      "parameters": {
     *          "domain_url": "https://alertlogic.okta.com/",
     *          "api_key": "api_key_123456",
     *          "collection_start_ts": "56726151727"
     *      }
     * }
     *
     * @param accountId AIMS Account ID
     * @param data The collector request body
     * @returns a promise with the subscriptions
     *
     * @remarks
     * https://console.product.dev.alertlogic.com/api/applications/index.html#api-Collectors-DeployCollector
     */
    deployACollector(accountId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.post({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/collectors`,
                data: data
            });
        });
    }
    /**
     * Deletes deployed collector by id
     * DELETE
     * /applications/v1/:account_id/collectors/:collector_id
     *
     * @param accountId The AIMS Account ID
     * @param collectorId A v4 UUID generated when collector is deployed
     * @returns just the status code
     *
     * @remarks
     * https://api.product.dev.alertlogic.com/applications/v1/01000001/rules/B37CEE84-6D27-4D0F-943C-F23937587574
     */
    deleteADeployedCollector(accountId, collectorId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.delete({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/collectors/${collectorId}`
            });
        });
    }
    /**
     * Updates an already deployed collector with given parameters
     * PUT
     * /applications/v1/:account_id/collectors/:collector_id
     *
     * @param accountId The AIMS Account ID
     * @param collectorId A v4 UUID generated when collector is deployed
     *
     * @remarks
     * https://console.product.dev.alertlogic.com/api/applications/index.html#api-Collectors-UpdateDeployedCollector
     */
    updateADeployedCollector(accountId, collectorId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: `/collectors/${collectorId}`,
                data: data
            });
        });
    }
    /**
     * Return the attributes list
     * GET
     * /applications/v1/:account_id/attributes
     * "https://api.product.dev.alertlogic.com/applications/v1/01000001/attributes"
     *
     *  @param accountId AIMS Account ID
     *  @returns a promise with the attributes list
     *
     *  @remarks
     *  https://console.product.dev.alertlogic.com/api/applications
     */
    getAllAttributes(accountId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                version: this.serviceVersion,
                account_id: accountId,
                path: '/attributes'
            });
        });
    }
}

/* tslint:disable:variable-name */
const AlApplicationsClient = core.AlGlobalizer.instantiate("AlApplicationsClient", () => new AlApplicationsClientInstance());

/* tslint:disable:variable-name */
class ExclusionsRulesDescriptor {
    constructor() {
        this.enabled = true;
        this.features = [];
        this.blackouts = [];
        this.assets = [];
        this.details = [];
        this.modified = [];
    }
    static import(rawData) {
        let exclusion = new ExclusionsRulesDescriptor();
        if (rawData.hasOwnProperty('id')) {
            exclusion.id = rawData.id;
        }
        exclusion.name = rawData.hasOwnProperty('name') ? rawData.name : null;
        exclusion.description = rawData.hasOwnProperty('description') ? rawData.description : null;
        exclusion.enabled = rawData.hasOwnProperty('enabled') ? (typeof rawData.enabled === 'string') ? (rawData.enabled === 'true') ? true : false : rawData.enabled : true;
        if (rawData.hasOwnProperty('features') && Array.isArray(rawData.features)) {
            for (let i = 0; i < rawData.features.length; i++) {
                exclusion.features.push(rawData.features[i]);
            }
        }
        if (rawData.hasOwnProperty('blackouts') && Array.isArray(rawData.blackouts)) {
            for (let i = 0; i < rawData.blackouts.length; i++) {
                exclusion.blackouts.push(rawData.blackouts[i].hasOwnProperty('resolution') ? ExclusionsBlackouts.import(rawData.blackouts[i]) : new ExclusionsBlackouts());
            }
        }
        if (rawData.hasOwnProperty('assets') && Array.isArray(rawData.assets)) {
            for (let i = 0; i < rawData.assets.length; i++) {
                exclusion.assets.push(rawData.assets[i].hasOwnProperty('type') ? ExclusionsAssets.import(rawData.assets[i]) : new ExclusionsAssets());
            }
        }
        if (rawData.hasOwnProperty('details') && Array.isArray(rawData.details)) {
            for (let i = 0; i < rawData.details.length; i++) {
                exclusion.details.push(rawData.details[i].hasOwnProperty('feature') ? ExlusionsDetails.import(rawData.details[i]) : new ExlusionsDetails());
            }
        }
        if (typeof (rawData === null || rawData === void 0 ? void 0 : rawData.modified) === 'object') {
            exclusion.modified.push((rawData.modified.hasOwnProperty('at') || rawData.modified.hasOwnProperty('by')) ? ExclusionsModified.import(rawData.modified) : new ExclusionsModified());
        }
        return exclusion;
    }
    update(rule) {
        this.id = rule.id;
        this.name = rule.name;
        this.description = rule.description;
        this.enabled = rule.enabled;
        this.features = rule.features;
        this.blackouts = rule.blackouts;
        this.assets = rule.assets;
        this.details = rule.details;
    }
}
/**
 *  TimeScheduleDescriptor provides a class to describe any schedule time, along with its
 *  raw properties and annotations.
 */
class TimeScheduleDescriptor {
    constructor(rawData) {
        this.isCertainHoursChecked = false;
        this.hourWindow = "12";
        this.hours = "00";
        this.minutes = "00";
        if (rawData.hasOwnProperty('isCertainHoursChecked')) {
            this.isCertainHoursChecked = rawData.isCertainHoursChecked;
        }
        if (rawData.hasOwnProperty('hourWindow')) {
            this.hourWindow = rawData.hourWindow;
        }
        if (rawData.hasOwnProperty('hours')) {
            this.hours = rawData.hours;
        }
        if (rawData.hasOwnProperty('minutes')) {
            this.minutes = rawData.minutes;
        }
    }
}
class ExclusionsBlackouts {
    constructor() { }
    static import(rawData) {
        let blackout = new ExclusionsBlackouts();
        blackout.resolution = rawData.hasOwnProperty('resolution') ? rawData.resolution : "permanent";
        if (rawData.hasOwnProperty('day_of_week')) {
            blackout.day_of_week = rawData.day_of_week;
        }
        if (rawData.hasOwnProperty('day_of_month')) {
            blackout.day_of_month = rawData.day_of_month;
        }
        if (rawData.hasOwnProperty('date')) {
            blackout.date = rawData.date;
        }
        if (rawData.hasOwnProperty('start_time')) {
            blackout.start_time = rawData.start_time;
        }
        if (rawData.hasOwnProperty('end_time')) {
            blackout.end_time = rawData.end_time;
        }
        return blackout;
    }
}
class ExclusionsAssets {
    constructor() { }
    static import(rawData) {
        let asset = new ExclusionsAssets();
        asset.type = rawData.hasOwnProperty('type') ? rawData.type : "asset";
        if (rawData.hasOwnProperty('asset_type')) {
            asset.asset_type = rawData.asset_type;
        }
        if (rawData.hasOwnProperty('value')) {
            asset.value = rawData.value;
        }
        if (rawData.hasOwnProperty('key')) {
            asset.key = rawData.key;
        }
        return asset;
    }
}
class ExlusionsDetails {
    constructor() { }
    static import(rawData) {
        let detail = new ExlusionsDetails();
        detail.feature = rawData.hasOwnProperty('feature') ? rawData.feature : "scan";
        if (rawData.hasOwnProperty('scan_type')) {
            detail.scan_type = rawData.scan_type;
        }
        if (rawData.hasOwnProperty('port')) {
            detail.port = rawData.port;
        }
        if (rawData.hasOwnProperty('proto')) {
            detail.proto = rawData.proto;
        }
        if (rawData.hasOwnProperty('ports') && Array.isArray(rawData.ports)) {
            detail.ports = [];
            for (let i = 0; i < rawData.ports.length; i++) {
                if (typeof rawData.ports[i] === 'string' || typeof rawData.ports[i] === 'number') {
                    detail.ports.push(rawData.ports[i]);
                }
            }
        }
        if (rawData.hasOwnProperty('cidr')) {
            detail.cidr = rawData.cidr;
        }
        return detail;
    }
}
class ExclusionsModified {
    constructor() { }
    static import(rawData) {
        let modified = new ExclusionsModified();
        if (rawData.hasOwnProperty('at')) {
            modified.at = rawData.at;
        }
        if (rawData.hasOwnProperty('by')) {
            modified.by = rawData.by;
        }
        return modified;
    }
}
class ExclusionsRulesSnapshot {
    constructor() {
        this.rules = [];
    }
    /**
     *  @method ExclusionsRulesSnapshot.import
     *
     *  This method expects to receive the raw object response from exclusions endpoint
     *  /exclusions/v1/{accountId}/{deploymentId}/rules
     *  It returns a populated instance of type ExclusionsRulesSnapshot.
     */
    static import(rawData) {
        let rules = new ExclusionsRulesSnapshot();
        if (rawData.hasOwnProperty('rules') && Array.isArray(rawData.rules)) {
            for (let i = 0; i < rawData.rules.length; i++) {
                rules.rules.push(rawData.rules[i].hasOwnProperty('id') ? ExclusionsRulesDescriptor.import(rawData.rules[i]) : new ExclusionsRulesDescriptor());
            }
        }
        return rules;
    }
}
class CidrType {
    static import(rawData) {
        let item = new CidrType();
        item.id = rawData.hasOwnProperty('id') ? rawData.id : '';
        item.protocol = rawData.hasOwnProperty('protocol') ? rawData.protocol : '';
        item.cidr = rawData.hasOwnProperty('cidr') ? rawData.cidr : '';
        item.port = rawData.hasOwnProperty('port') ? rawData.port : '';
        item.networkKey = rawData.hasOwnProperty('networkKey') ? rawData.networkKey : '';
        item.asset_type = rawData.hasOwnProperty('asset_type') ? rawData.asset_type : '';
        item.description = rawData.hasOwnProperty('description') ? rawData.description : '';
        return item;
    }
}
class AllExclusionsToSave {
}
exports.BlackoutsResolution = void 0;
(function (BlackoutsResolution) {
    BlackoutsResolution["weekly"] = "weekly";
    BlackoutsResolution["monthly"] = "monthly";
    BlackoutsResolution["exact_date"] = "exact_date";
    BlackoutsResolution["permanent"] = "permanent";
})(exports.BlackoutsResolution || (exports.BlackoutsResolution = {}));
exports.AssetType = void 0;
(function (AssetType) {
    AssetType["cidr"] = "cidr";
    AssetType["asset"] = "asset";
    AssetType["tag"] = "tag";
})(exports.AssetType || (exports.AssetType = {}));
exports.DetailsFeature = void 0;
(function (DetailsFeature) {
    DetailsFeature["scan"] = "scan";
    DetailsFeature["ids"] = "ids";
})(exports.DetailsFeature || (exports.DetailsFeature = {}));
exports.ScanType = void 0;
(function (ScanType) {
    ScanType["vulnerability"] = "vulnerability";
    ScanType["pci"] = "pci";
    ScanType["discovery"] = "discovery";
    ScanType["external"] = "external";
})(exports.ScanType || (exports.ScanType = {}));
exports.Protocols = void 0;
(function (Protocols) {
    Protocols["tcp"] = "tcp";
    Protocols["udp"] = "udp";
    Protocols["icmp"] = "icmp";
    Protocols["asterisk"] = "*";
})(exports.Protocols || (exports.Protocols = {}));

class AlExclusionsClientInstance {
    constructor() {
        this.serviceName = 'exclusions';
        this.serviceVersion = 'v1';
    }
    /**
     * @remarks https://console.cloudinsight.alertlogic.com/api/exclusions/index.html#api-Exclusion_Rules-GetRules
     */
    listRules(accountId, deploymentId, searchParams) {
        return __awaiter(this, void 0, void 0, function* () {
            const rawData = yield core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${deploymentId}/rules`,
                params: searchParams
            });
            return ExclusionsRulesSnapshot.import(rawData);
        });
    }
    /**
     * @remarks https://console.cloudinsight.alertlogic.com/api/exclusions/index.html#api-Exclusion_Rules-GetRule
     */
    getRule(accountId, deploymentId, ruleId) {
        return __awaiter(this, void 0, void 0, function* () {
            const rawData = yield core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${deploymentId}/rules/${ruleId}`,
            });
            return ExclusionsRulesDescriptor.import(rawData);
        });
    }
    /**
     * @remarks https://console.cloudinsight.alertlogic.com/api/exclusions/index.html#api-Exclusion_Rules-DeleteExclusionRule
     */
    deleteRule(accountId, deploymentId, ruleId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.delete({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${deploymentId}/rules/${ruleId}`,
            });
        });
    }
    /**
     * @remarks https://console.cloudinsight.alertlogic.com/api/exclusions/index.html#api-Exclusion_Rules-CreateExclusionRule
     */
    createRule(accountId, deploymentId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            const rawData = core.AlDefaultClient.post({
                data,
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${deploymentId}/rules`,
            });
            return ExclusionsRulesDescriptor.import(rawData);
        });
    }
    /**
     * @remarks https://console.cloudinsight.alertlogic.com/api/exclusions/index.html#api-Exclusion_Rules-UpdateExclusionRule
     */
    updateRule(accountId, deploymentId, ruleId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            const rawData = core.AlDefaultClient.put({
                data,
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${deploymentId}/rules/${ruleId}`,
            });
            return ExclusionsRulesDescriptor.import(rawData);
        });
    }
    /**
     * @remarks https://console.product.dev.alertlogic.com/api/exclusions/#api-Is_Asset_Excluded_API-ApplyExclusionRule
     */
    isExcluded(accountId, deploymentId, assetType, assetKey, feature = "scan", searchParams) {
        return __awaiter(this, void 0, void 0, function* () {
            const rawData = yield core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: 'v2',
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${deploymentId}/is_excluded/${feature}/${assetType}/${assetKey}`,
                params: searchParams
            });
            return rawData ? ExclusionsRulesDescriptor.import(rawData) : new ExclusionsRulesDescriptor();
        });
    }
}

/* tslint:disable:variable-name */
const AlExclusionsClient = core.AlGlobalizer.instantiate("AlExclusionsClient", () => new AlExclusionsClientInstance());

class AlCredentialsClientInstance {
    /* istanbul ignore next */
    constructor() {
        this.serviceVersion = 'v1';
        this.serviceName = 'credentials';
    }
    /**
     * Delete scan credentials for an asset
     * DELETE
     * /credentials/v1/:account_id/:environment_id/:asset_type/scan/:credential_type/:asset_key
     * "https://api.cloudinsight.alertlogic.com/credentials/v1/01000001/5955C10B-33A2-41A0-9E73-10CBD51FA9CF/host/scan/ssh/aws/us-west-2/host/i-4e751943"
     */
    deleteHostScanCredentials(accountId, environmentId, assetType, credentialType, assetKey) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.delete({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${environmentId}/${assetType}/scan/${credentialType}/${assetKey}`,
            });
        });
    }
    /**
     * @deprecatd use getScanCredentials instead
     * Get scan credentials for a host
     * GET
     * /credentials/v1/:account_id/:environment_id/host/scan/:asset_key
     * "https://api.cloudinsight.alertlogic.com/credentials/v1/01000001/5955C10B-33A2-41A0-9E73-10CBD51FA9CF/host/scan/aws/us-west-2/host/i-4e751943"
     */
    getHostScanCredentials(accountId, environmentId, assetKey) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${environmentId}/host/scan/${assetKey}`,
            });
        });
    }
    /**
    * Get scan credentials for an asset
    * GET
    * /credentials/v1/:account_id/:environment_id/:asset_type/scan/:asset_key
    * "https://api.product.dev.alertlogic.com/credentials/v1/134249236/0C51E404-4BB4-4228-B6B7-32B43029C76F/vpc/scan/dc/network/D4BC698D-54E1-4422-9F0B-9F21B064A9E4"
    */
    getScanCredentials(accountId, deploymentId, assetType, assetKey) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${deploymentId}/${assetType}/scan/${assetKey}`,
            });
        });
    }
    /**
     * Get scan credentials for all hosts
     * GET
     * /credentials/v1/:account_id/:environment_id/host/scan
     * "https://api.cloudinsight.alertlogic.com/credentials/v1/01000001/5955C10B-33A2-41A0-9E73-10CBD51FA9CF/host/scan"
     */
    getAllHostScanCredentials(accountId, environmentId) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.get({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${environmentId}/host/scan`,
            });
        });
    }
    /**
     * Store scan credentials for an asset
     * PUT
     * /credentials/v1/:account_id/:environment_id/:asset_type/scan/:asset_key
     * "https://api.cloudinsight.alertlogic.com/credentials/v1/01000001/5955C10B-33A2-41A0-9E73-10CBD51FA9CF/host/scan/aws/us-west-2/host/i-4e751943"
     * -d '{"name": "Cred", "type": "ssh", "sub_type": "key", "username": "", "key": "PRIVATE KEY"}'
     */
    storeHostScanCredential(accountId, environmentId, assetType, assetKey, credential) {
        return __awaiter(this, void 0, void 0, function* () {
            return core.AlDefaultClient.put({
                service_stack: core.AlLocation.InsightAPI,
                version: this.serviceVersion,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/${environmentId}/${assetType}/scan/${assetKey}`,
                data: credential,
            });
        });
    }
    getAssetsCredentialsByType(accountId, deploymentId, type, assetId) {
        return core.AlDefaultClient.get({
            service_stack: core.AlLocation.InsightAPI,
            version: this.serviceVersion,
            service_name: this.serviceName,
            account_id: accountId,
            path: `/${deploymentId}/${type}/scan${assetId}`,
        });
    }
}

class AlCredentialslientV2Instance {
    /* istanbul ignore next */
    constructor(client = core.AlDefaultClient) {
        this.client = client;
        this.serviceVersion = 'v2';
        this.serviceName = 'credentials';
    }
    /**
     * Create Credential
     * POST
     * /credentials/v2/:account_id/credentials
     * "https://api.cloudinsight.alertlogic.com/credentials/v1/01000001/credentials"
     * -d '{"name":"IAM Role","secrets":{"type":"aws_iam_role","arn":"ARN"}}'
     */
    create(accountId, credential) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.post({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: '/credentials',
                version: this.serviceVersion,
                data: credential,
            });
        });
    }
    /**
     * Delete Credential
     * DELETE
     * /credentials/v2/:account_id/credentials/:credential_id
     * "https://api.cloudinsight.alertlogic.com/credentials/v1/01000001/credentials/5955C10B-33A2-41A0-9E73-10CBD51FA9CF"
     */
    delete(accountId, credentialId) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.delete({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/credentials/${credentialId}`,
                version: this.serviceVersion,
            });
        });
    }
    /**
     * Get credential
     * GET
     * /credentials/v2/:account_id/credentials/:credential_id
     * "https://api.cloudinsight.alertlogic.com/credentials/v2/01000001/credentials/BD7592C5-0111-1005-83EE-7831C1BAEAE6"
     */
    getById(accountId, credentialId) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/credentials/${credentialId}`,
                version: this.serviceVersion,
            });
        });
    }
    /**
     * List credentials
     * GET
     * /credentials/v2/:account_id/credentials
     * "https://api.cloudinsight.alertlogic.com/credentials/v2/01000001/credentials"
     */
    listAll(accountId) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: '/credentials/',
                version: this.serviceVersion,
            });
        });
    }
}

/* tslint:disable:variable-name */
const AlCredentialsClient = core.AlGlobalizer.instantiate('al.credentials', () => new AlCredentialsClientInstance());
const AlCredentialsClientV2 = core.AlGlobalizer.instantiate('al.credentialsv2', () => new AlCredentialslientV2Instance());

/**
 * Config V2 Public API endpoints Implementation
 */
class AlConfigClientV2 {
    constructor(client = core.AlDefaultClient) {
        this.client = client;
        this.serviceVersion = 'v2';
        this.serviceName = 'config';
    }
    /**
     * Returns a list of configurations for assets of a given type that match given filters
     * @param accountId
     * @param qParams
     * @returns list of configurations
     * https://console.account.alertlogic.com/users/api/config/#api-Configuration-GetAssetConfigs
     */
    listConfigs(accountId, qParams) {
        return this.client.get({
            service_stack: core.AlLocation.InsightAPI,
            version: 'v2',
            service_name: 'config',
            account_id: accountId,
            path: `/configs`,
            params: qParams
        });
    }
}

/* tslint:disable:variable-name */
const ALConfigV2 = core.AlGlobalizer.instantiate("AlConfigClientV2", () => new AlConfigClientV2());

class OTISClient {
    constructor() {
        this.client = core.AlDefaultClient;
        this.serviceName = 'otis';
        this.version = 'v3';
    }
    /**
     * Create Option
     */
    createOption(accountId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.post({
                data,
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: '/options',
                version: this.version
            });
        });
    }
    /**
     * Get Option
     */
    getOption(accountId, optionId) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/options/${optionId}`,
                version: this.version,
            });
        });
    }
    /**
     * List Options
     */
    listOptions(accountId, params) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/options/`,
                version: this.version,
                params: params
            });
        });
    }
    /**
     * Delete Option
     */
    deleteOption(accountId, optionId) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.delete({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/options/${optionId}`,
                version: this.version,
            });
        });
    }
    /**
     * Update Option Value
     *
     * value: set as any because of the API flexibility, from docs: value - arbitrary JSON data
     */
    updateOptionValue(accountId, optionId, value) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/options/${optionId}`,
                version: this.version,
                data: {
                    value,
                },
            });
        });
    }
    /**
     * Resolve Option Values
     */
    resolveOptionValues(accountId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.post({
                data,
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: '/options/resolve',
                version: this.version
            });
        });
    }
}
const otisClient = new OTISClient();

class OtisClientV2 {
    constructor() {
        this.client = core.AlDefaultClient;
        this.serviceName = 'otis';
        this.version = 'v2';
    }
    /**
     * Create Option
     */
    createOption(accountId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.post({
                data,
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: '/options',
                version: this.version
            });
        });
    }
    /**
     * Get Option
     */
    getOption(accountId, optionId) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/options/${optionId}`,
                version: this.version,
            });
        });
    }
    /**
     * List Options
     */
    listOptions(accountId, params) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.get({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/options/`,
                version: this.version,
                params: params
            });
        });
    }
    /**
     * Delete Option
     */
    deleteOption(accountId, optionId) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.delete({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/options/${optionId}`,
                version: this.version,
            });
        });
    }
    /**
     * Update Option Value
     *
     * value: set as any because of the API flexibility, from docs: value - arbitrary JSON data
     */
    updateOptionValue(accountId, optionId, value) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.put({
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: `/options/${optionId}`,
                version: this.version,
                data: {
                    value,
                },
            });
        });
    }
    /**
     * Resolve Option Values
     */
    resolveOptionValues(accountId, data) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.client.post({
                data,
                service_stack: core.AlLocation.InsightAPI,
                service_name: this.serviceName,
                account_id: accountId,
                path: '/options/resolve',
                version: this.version
            });
        });
    }
}
const otisClientV2 = new OtisClientV2();

exports.ALConfigV2 = ALConfigV2;
exports.AlApplicationsClient = AlApplicationsClient;
exports.AlApplicationsClientInstance = AlApplicationsClientInstance;
exports.AlConfigClientV2 = AlConfigClientV2;
exports.AlCredentialsClient = AlCredentialsClient;
exports.AlCredentialsClientInstance = AlCredentialsClientInstance;
exports.AlCredentialsClientV2 = AlCredentialsClientV2;
exports.AlCredentialslientV2Instance = AlCredentialslientV2Instance;
exports.AlExclusionsClient = AlExclusionsClient;
exports.AlExclusionsClientInstance = AlExclusionsClientInstance;
exports.AlFimClient = AlFimClient;
exports.AlFimClientInstance = AlFimClientInstance;
exports.AlPoliciesClient = AlPoliciesClient;
exports.AlPoliciesClientInstance = AlPoliciesClientInstance;
exports.AlScanSchedulerClientInstanceV2 = AlScanSchedulerClientInstanceV2;
exports.AlScanSchedulerClientV2 = AlScanSchedulerClientV2;
exports.AlSchedulerClient = AlSchedulerClient;
exports.AlSchedulerClientInstance = AlSchedulerClientInstance;
exports.AlWatchlistClient = AlWatchlistClient;
exports.AlWatchlistClientInstance = AlWatchlistClientInstance;
exports.AlWhitelistClient = AlWhitelistClient;
exports.AllExclusionsToSave = AllExclusionsToSave;
exports.AlwsWhitelistClientInstance = AlwsWhitelistClientInstance;
exports.CidrType = CidrType;
exports.ExclusionsAssets = ExclusionsAssets;
exports.ExclusionsBlackouts = ExclusionsBlackouts;
exports.ExclusionsModified = ExclusionsModified;
exports.ExclusionsRulesDescriptor = ExclusionsRulesDescriptor;
exports.ExclusionsRulesSnapshot = ExclusionsRulesSnapshot;
exports.ExlusionsDetails = ExlusionsDetails;
exports.OTISClient = otisClient;
exports.OtisClientV2 = otisClientV2;
exports.ThemisClient = themisClient;
exports.TimeScheduleDescriptor = TimeScheduleDescriptor;
exports.findPolicy = findPolicy;
exports.getFullPath = getFullPath;
exports.nixRegex = nixRegex;
exports.parseNodeFlavor = parseNodeFlavor;
exports.parsePolicyName = parsePolicyName;
exports.windowsDirectoryRegex = windowsDirectoryRegex;
exports.windowsRegistryRegex = windowsRegistryRegex;
//# sourceMappingURL=al-core-configuration.es5.js.map
