"use strict";
/*
 *  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *  SPDX-License-Identifier: Apache-2.0
 */
Object.defineProperty(exports, "__esModule", { value: true });
const workbench_core_base_1 = require("@aws/workbench-core-base");
class SagemakerNotebookEnvironmentConnectionService {
    /**
     * Get credentials for connecting to the environment
     */
    /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
    async getAuthCreds(instanceName, context) {
        const region = process.env.AWS_REGION;
        const awsService = new workbench_core_base_1.AwsService({ region });
        const hostingAccountAwsService = await awsService.getAwsServiceForRole({
            roleArn: context.roleArn,
            roleSessionName: `SagemakerConnect-${Date.now()}`,
            externalId: context.externalId,
            region
        });
        const response = await hostingAccountAwsService.clients.sagemaker.createPresignedNotebookInstanceUrl({
            NotebookInstanceName: instanceName
        });
        return { url: response.AuthorizedUrl };
    }
    /**
     * Instructions for connecting to the workspace that can be shown verbatim in the UI
     */
    getConnectionInstruction() {
        // "url" is the key of the response returned by the method `getAuthCreds`
        const link = {
            type: 'link',
            hrefKey: 'url',
            text: 'Sagemaker URL'
        };
        return Promise.resolve(`To access Sagemaker Notebook, open #${JSON.stringify(link)}`);
    }
}
exports.default = SagemakerNotebookEnvironmentConnectionService;
//# sourceMappingURL=sagemakerNotebookEnvironmentConnectionService.js.map