"use strict";
/*
 *  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *  SPDX-License-Identifier: Apache-2.0
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.SWBEnvironmentService = void 0;
const workbench_core_environments_1 = require("@aws/workbench-core-environments");
class SWBEnvironmentService {
    constructor(environmentService) {
        this._environmentService = environmentService;
    }
    async listEnvironments(request) {
        var _a, _b;
        const parsedRequest = workbench_core_environments_1.ListEnvironmentsServiceRequestParser.parse(request); //removing project properties
        //Replacing project prop for dependency
        if (((_a = request.filter) === null || _a === void 0 ? void 0 : _a.projectId) && parsedRequest.filter)
            parsedRequest.filter.dependency = request.filter.projectId;
        if (((_b = request.sort) === null || _b === void 0 ? void 0 : _b.projectId) && parsedRequest.sort)
            parsedRequest.sort.dependency = request.sort.projectId;
        return await this._environmentService.listEnvironments(parsedRequest);
    }
}
exports.SWBEnvironmentService = SWBEnvironmentService;
//# sourceMappingURL=swbEnvironmentService.js.map