"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const apis_1 = require("./apis");
const ClustersService_1 = tslib_1.__importDefault(require("./ClustersService"));
const DiscoveryImageFormService = {
    update(clusterId, clusterTags, infraEnvId, formValues, ocmPullSecret, isIpxeImage) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const proxyParams = {
                httpProxy: formValues.httpProxy,
                httpsProxy: formValues.httpsProxy,
                noProxy: formValues.noProxy,
                // TODO(mlibra): Does the user need to change pull-secret?
                pullSecret: ocmPullSecret || undefined,
                sshPublicKey: formValues.sshPublicKey,
            };
            const infraEnvParams = {
                proxy: {
                    httpProxy: formValues.httpProxy,
                    httpsProxy: formValues.httpsProxy,
                    noProxy: formValues.noProxy,
                },
                sshAuthorizedKey: formValues.sshPublicKey,
                pullSecret: ocmPullSecret || undefined,
                staticNetworkConfig: formValues.staticNetworkConfig,
                additionalTrustBundle: formValues.trustBundle,
                imageType: isIpxeImage ? undefined : formValues.imageType,
            };
            const { data: updatedCluster } = yield ClustersService_1.default.update(clusterId, clusterTags, proxyParams);
            apis_1.InfraEnvsAPI.abortLastGetRequest();
            const { data: updatedInfraEnv } = yield apis_1.InfraEnvsAPI.update(infraEnvId, infraEnvParams);
            return { updatedCluster, updatedInfraEnv };
        });
    },
};
exports.default = DiscoveryImageFormService;
//# sourceMappingURL=DiscoveryImageFormService.js.map