"use strict";
// This file was auto-generated by Fern from our API Definition.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __awaiter = (this && this.__awaiter) || function (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());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmbedJobs = void 0;
const core = __importStar(require("../../../../core"));
const headers_1 = require("../../../../core/headers");
const environments = __importStar(require("../../../../environments"));
const errors = __importStar(require("../../../../errors/index"));
const serializers = __importStar(require("../../../../serialization/index"));
const Cohere = __importStar(require("../../../index"));
class EmbedJobs {
    constructor(_options = {}) {
        this._options = _options;
    }
    /**
     * The list embed job endpoint allows users to view all embed jobs history for that specific user.
     *
     * @param {EmbedJobs.RequestOptions} requestOptions - Request-specific configuration.
     *
     * @throws {@link Cohere.BadRequestError}
     * @throws {@link Cohere.UnauthorizedError}
     * @throws {@link Cohere.ForbiddenError}
     * @throws {@link Cohere.NotFoundError}
     * @throws {@link Cohere.UnprocessableEntityError}
     * @throws {@link Cohere.TooManyRequestsError}
     * @throws {@link Cohere.InvalidTokenError}
     * @throws {@link Cohere.ClientClosedRequestError}
     * @throws {@link Cohere.InternalServerError}
     * @throws {@link Cohere.NotImplementedError}
     * @throws {@link Cohere.ServiceUnavailableError}
     * @throws {@link Cohere.GatewayTimeoutError}
     *
     * @example
     *     await client.embedJobs.list()
     */
    list(requestOptions) {
        return core.HttpResponsePromise.fromPromise(this.__list(requestOptions));
    }
    __list(requestOptions) {
        return __awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
            const _headers = (0, headers_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_1.mergeOnlyDefinedHeaders)({
                Authorization: yield this._getAuthorizationHeader(),
                "X-Client-Name": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.clientName) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.clientName,
            }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
            const _response = yield ((_d = this._options.fetcher) !== null && _d !== void 0 ? _d : core.fetcher)({
                url: core.url.join((_f = (_e = (yield core.Supplier.get(this._options.baseUrl))) !== null && _e !== void 0 ? _e : (yield core.Supplier.get(this._options.environment))) !== null && _f !== void 0 ? _f : environments.CohereEnvironment.Production, "v1/embed-jobs"),
                method: "GET",
                headers: _headers,
                queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
                timeoutMs: ((_j = (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.timeoutInSeconds) !== null && _j !== void 0 ? _j : 300) * 1000,
                maxRetries: (_k = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _k !== void 0 ? _k : (_l = this._options) === null || _l === void 0 ? void 0 : _l.maxRetries,
                abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
                fetchFn: (_m = this._options) === null || _m === void 0 ? void 0 : _m.fetch,
                logging: this._options.logging,
            });
            if (_response.ok) {
                return {
                    data: serializers.ListEmbedJobResponse.parseOrThrow(_response.body, {
                        unrecognizedObjectKeys: "passthrough",
                        allowUnrecognizedUnionMembers: true,
                        allowUnrecognizedEnumValues: true,
                        skipValidation: true,
                        breadcrumbsPrefix: ["response"],
                    }),
                    rawResponse: _response.rawResponse,
                };
            }
            if (_response.error.reason === "status-code") {
                switch (_response.error.statusCode) {
                    case 400:
                        throw new Cohere.BadRequestError(_response.error.body, _response.rawResponse);
                    case 401:
                        throw new Cohere.UnauthorizedError(_response.error.body, _response.rawResponse);
                    case 403:
                        throw new Cohere.ForbiddenError(_response.error.body, _response.rawResponse);
                    case 404:
                        throw new Cohere.NotFoundError(_response.error.body, _response.rawResponse);
                    case 422:
                        throw new Cohere.UnprocessableEntityError(_response.error.body, _response.rawResponse);
                    case 429:
                        throw new Cohere.TooManyRequestsError(_response.error.body, _response.rawResponse);
                    case 498:
                        throw new Cohere.InvalidTokenError(_response.error.body, _response.rawResponse);
                    case 499:
                        throw new Cohere.ClientClosedRequestError(_response.error.body, _response.rawResponse);
                    case 500:
                        throw new Cohere.InternalServerError(_response.error.body, _response.rawResponse);
                    case 501:
                        throw new Cohere.NotImplementedError(_response.error.body, _response.rawResponse);
                    case 503:
                        throw new Cohere.ServiceUnavailableError(_response.error.body, _response.rawResponse);
                    case 504:
                        throw new Cohere.GatewayTimeoutError(_response.error.body, _response.rawResponse);
                    default:
                        throw new errors.CohereError({
                            statusCode: _response.error.statusCode,
                            body: _response.error.body,
                            rawResponse: _response.rawResponse,
                        });
                }
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.CohereError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                        rawResponse: _response.rawResponse,
                    });
                case "timeout":
                    throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/embed-jobs.");
                case "unknown":
                    throw new errors.CohereError({
                        message: _response.error.errorMessage,
                        rawResponse: _response.rawResponse,
                    });
            }
        });
    }
    /**
     * This API launches an async Embed job for a [Dataset](https://docs.cohere.com/docs/datasets) of type `embed-input`. The result of a completed embed job is new Dataset of type `embed-output`, which contains the original text entries and the corresponding embeddings.
     *
     * @param {Cohere.CreateEmbedJobRequest} request
     * @param {EmbedJobs.RequestOptions} requestOptions - Request-specific configuration.
     *
     * @throws {@link Cohere.BadRequestError}
     * @throws {@link Cohere.UnauthorizedError}
     * @throws {@link Cohere.ForbiddenError}
     * @throws {@link Cohere.NotFoundError}
     * @throws {@link Cohere.UnprocessableEntityError}
     * @throws {@link Cohere.TooManyRequestsError}
     * @throws {@link Cohere.InvalidTokenError}
     * @throws {@link Cohere.ClientClosedRequestError}
     * @throws {@link Cohere.InternalServerError}
     * @throws {@link Cohere.NotImplementedError}
     * @throws {@link Cohere.ServiceUnavailableError}
     * @throws {@link Cohere.GatewayTimeoutError}
     *
     * @example
     *     await client.embedJobs.create({
     *         model: "model",
     *         datasetId: "dataset_id",
     *         inputType: "search_document"
     *     })
     */
    create(request, requestOptions) {
        return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
    }
    __create(request, requestOptions) {
        return __awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
            const _headers = (0, headers_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_1.mergeOnlyDefinedHeaders)({
                Authorization: yield this._getAuthorizationHeader(),
                "X-Client-Name": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.clientName) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.clientName,
            }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
            const _response = yield ((_d = this._options.fetcher) !== null && _d !== void 0 ? _d : core.fetcher)({
                url: core.url.join((_f = (_e = (yield core.Supplier.get(this._options.baseUrl))) !== null && _e !== void 0 ? _e : (yield core.Supplier.get(this._options.environment))) !== null && _f !== void 0 ? _f : environments.CohereEnvironment.Production, "v1/embed-jobs"),
                method: "POST",
                headers: _headers,
                contentType: "application/json",
                queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
                requestType: "json",
                body: serializers.CreateEmbedJobRequest.jsonOrThrow(request, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                }),
                timeoutMs: ((_j = (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.timeoutInSeconds) !== null && _j !== void 0 ? _j : 300) * 1000,
                maxRetries: (_k = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _k !== void 0 ? _k : (_l = this._options) === null || _l === void 0 ? void 0 : _l.maxRetries,
                abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
                fetchFn: (_m = this._options) === null || _m === void 0 ? void 0 : _m.fetch,
                logging: this._options.logging,
            });
            if (_response.ok) {
                return {
                    data: serializers.CreateEmbedJobResponse.parseOrThrow(_response.body, {
                        unrecognizedObjectKeys: "passthrough",
                        allowUnrecognizedUnionMembers: true,
                        allowUnrecognizedEnumValues: true,
                        skipValidation: true,
                        breadcrumbsPrefix: ["response"],
                    }),
                    rawResponse: _response.rawResponse,
                };
            }
            if (_response.error.reason === "status-code") {
                switch (_response.error.statusCode) {
                    case 400:
                        throw new Cohere.BadRequestError(_response.error.body, _response.rawResponse);
                    case 401:
                        throw new Cohere.UnauthorizedError(_response.error.body, _response.rawResponse);
                    case 403:
                        throw new Cohere.ForbiddenError(_response.error.body, _response.rawResponse);
                    case 404:
                        throw new Cohere.NotFoundError(_response.error.body, _response.rawResponse);
                    case 422:
                        throw new Cohere.UnprocessableEntityError(_response.error.body, _response.rawResponse);
                    case 429:
                        throw new Cohere.TooManyRequestsError(_response.error.body, _response.rawResponse);
                    case 498:
                        throw new Cohere.InvalidTokenError(_response.error.body, _response.rawResponse);
                    case 499:
                        throw new Cohere.ClientClosedRequestError(_response.error.body, _response.rawResponse);
                    case 500:
                        throw new Cohere.InternalServerError(_response.error.body, _response.rawResponse);
                    case 501:
                        throw new Cohere.NotImplementedError(_response.error.body, _response.rawResponse);
                    case 503:
                        throw new Cohere.ServiceUnavailableError(_response.error.body, _response.rawResponse);
                    case 504:
                        throw new Cohere.GatewayTimeoutError(_response.error.body, _response.rawResponse);
                    default:
                        throw new errors.CohereError({
                            statusCode: _response.error.statusCode,
                            body: _response.error.body,
                            rawResponse: _response.rawResponse,
                        });
                }
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.CohereError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                        rawResponse: _response.rawResponse,
                    });
                case "timeout":
                    throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/embed-jobs.");
                case "unknown":
                    throw new errors.CohereError({
                        message: _response.error.errorMessage,
                        rawResponse: _response.rawResponse,
                    });
            }
        });
    }
    /**
     * This API retrieves the details about an embed job started by the same user.
     *
     * @param {string} id - The ID of the embed job to retrieve.
     * @param {EmbedJobs.RequestOptions} requestOptions - Request-specific configuration.
     *
     * @throws {@link Cohere.BadRequestError}
     * @throws {@link Cohere.UnauthorizedError}
     * @throws {@link Cohere.ForbiddenError}
     * @throws {@link Cohere.NotFoundError}
     * @throws {@link Cohere.UnprocessableEntityError}
     * @throws {@link Cohere.TooManyRequestsError}
     * @throws {@link Cohere.InvalidTokenError}
     * @throws {@link Cohere.ClientClosedRequestError}
     * @throws {@link Cohere.InternalServerError}
     * @throws {@link Cohere.NotImplementedError}
     * @throws {@link Cohere.ServiceUnavailableError}
     * @throws {@link Cohere.GatewayTimeoutError}
     *
     * @example
     *     await client.embedJobs.get("id")
     */
    get(id, requestOptions) {
        return core.HttpResponsePromise.fromPromise(this.__get(id, requestOptions));
    }
    __get(id, requestOptions) {
        return __awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
            const _headers = (0, headers_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_1.mergeOnlyDefinedHeaders)({
                Authorization: yield this._getAuthorizationHeader(),
                "X-Client-Name": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.clientName) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.clientName,
            }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
            const _response = yield ((_d = this._options.fetcher) !== null && _d !== void 0 ? _d : core.fetcher)({
                url: core.url.join((_f = (_e = (yield core.Supplier.get(this._options.baseUrl))) !== null && _e !== void 0 ? _e : (yield core.Supplier.get(this._options.environment))) !== null && _f !== void 0 ? _f : environments.CohereEnvironment.Production, `v1/embed-jobs/${core.url.encodePathParam(id)}`),
                method: "GET",
                headers: _headers,
                queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
                timeoutMs: ((_j = (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.timeoutInSeconds) !== null && _j !== void 0 ? _j : 300) * 1000,
                maxRetries: (_k = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _k !== void 0 ? _k : (_l = this._options) === null || _l === void 0 ? void 0 : _l.maxRetries,
                abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
                fetchFn: (_m = this._options) === null || _m === void 0 ? void 0 : _m.fetch,
                logging: this._options.logging,
            });
            if (_response.ok) {
                return {
                    data: serializers.EmbedJob.parseOrThrow(_response.body, {
                        unrecognizedObjectKeys: "passthrough",
                        allowUnrecognizedUnionMembers: true,
                        allowUnrecognizedEnumValues: true,
                        skipValidation: true,
                        breadcrumbsPrefix: ["response"],
                    }),
                    rawResponse: _response.rawResponse,
                };
            }
            if (_response.error.reason === "status-code") {
                switch (_response.error.statusCode) {
                    case 400:
                        throw new Cohere.BadRequestError(_response.error.body, _response.rawResponse);
                    case 401:
                        throw new Cohere.UnauthorizedError(_response.error.body, _response.rawResponse);
                    case 403:
                        throw new Cohere.ForbiddenError(_response.error.body, _response.rawResponse);
                    case 404:
                        throw new Cohere.NotFoundError(_response.error.body, _response.rawResponse);
                    case 422:
                        throw new Cohere.UnprocessableEntityError(_response.error.body, _response.rawResponse);
                    case 429:
                        throw new Cohere.TooManyRequestsError(_response.error.body, _response.rawResponse);
                    case 498:
                        throw new Cohere.InvalidTokenError(_response.error.body, _response.rawResponse);
                    case 499:
                        throw new Cohere.ClientClosedRequestError(_response.error.body, _response.rawResponse);
                    case 500:
                        throw new Cohere.InternalServerError(_response.error.body, _response.rawResponse);
                    case 501:
                        throw new Cohere.NotImplementedError(_response.error.body, _response.rawResponse);
                    case 503:
                        throw new Cohere.ServiceUnavailableError(_response.error.body, _response.rawResponse);
                    case 504:
                        throw new Cohere.GatewayTimeoutError(_response.error.body, _response.rawResponse);
                    default:
                        throw new errors.CohereError({
                            statusCode: _response.error.statusCode,
                            body: _response.error.body,
                            rawResponse: _response.rawResponse,
                        });
                }
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.CohereError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                        rawResponse: _response.rawResponse,
                    });
                case "timeout":
                    throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/embed-jobs/{id}.");
                case "unknown":
                    throw new errors.CohereError({
                        message: _response.error.errorMessage,
                        rawResponse: _response.rawResponse,
                    });
            }
        });
    }
    /**
     * This API allows users to cancel an active embed job. Once invoked, the embedding process will be terminated, and users will be charged for the embeddings processed up to the cancellation point. It's important to note that partial results will not be available to users after cancellation.
     *
     * @param {string} id - The ID of the embed job to cancel.
     * @param {EmbedJobs.RequestOptions} requestOptions - Request-specific configuration.
     *
     * @throws {@link Cohere.BadRequestError}
     * @throws {@link Cohere.UnauthorizedError}
     * @throws {@link Cohere.ForbiddenError}
     * @throws {@link Cohere.NotFoundError}
     * @throws {@link Cohere.UnprocessableEntityError}
     * @throws {@link Cohere.TooManyRequestsError}
     * @throws {@link Cohere.InvalidTokenError}
     * @throws {@link Cohere.ClientClosedRequestError}
     * @throws {@link Cohere.InternalServerError}
     * @throws {@link Cohere.NotImplementedError}
     * @throws {@link Cohere.ServiceUnavailableError}
     * @throws {@link Cohere.GatewayTimeoutError}
     *
     * @example
     *     await client.embedJobs.cancel("id")
     */
    cancel(id, requestOptions) {
        return core.HttpResponsePromise.fromPromise(this.__cancel(id, requestOptions));
    }
    __cancel(id, requestOptions) {
        return __awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
            const _headers = (0, headers_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_1.mergeOnlyDefinedHeaders)({
                Authorization: yield this._getAuthorizationHeader(),
                "X-Client-Name": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.clientName) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.clientName,
            }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
            const _response = yield ((_d = this._options.fetcher) !== null && _d !== void 0 ? _d : core.fetcher)({
                url: core.url.join((_f = (_e = (yield core.Supplier.get(this._options.baseUrl))) !== null && _e !== void 0 ? _e : (yield core.Supplier.get(this._options.environment))) !== null && _f !== void 0 ? _f : environments.CohereEnvironment.Production, `v1/embed-jobs/${core.url.encodePathParam(id)}/cancel`),
                method: "POST",
                headers: _headers,
                queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
                timeoutMs: ((_j = (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.timeoutInSeconds) !== null && _j !== void 0 ? _j : 300) * 1000,
                maxRetries: (_k = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _k !== void 0 ? _k : (_l = this._options) === null || _l === void 0 ? void 0 : _l.maxRetries,
                abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
                fetchFn: (_m = this._options) === null || _m === void 0 ? void 0 : _m.fetch,
                logging: this._options.logging,
            });
            if (_response.ok) {
                return { data: undefined, rawResponse: _response.rawResponse };
            }
            if (_response.error.reason === "status-code") {
                switch (_response.error.statusCode) {
                    case 400:
                        throw new Cohere.BadRequestError(_response.error.body, _response.rawResponse);
                    case 401:
                        throw new Cohere.UnauthorizedError(_response.error.body, _response.rawResponse);
                    case 403:
                        throw new Cohere.ForbiddenError(_response.error.body, _response.rawResponse);
                    case 404:
                        throw new Cohere.NotFoundError(_response.error.body, _response.rawResponse);
                    case 422:
                        throw new Cohere.UnprocessableEntityError(_response.error.body, _response.rawResponse);
                    case 429:
                        throw new Cohere.TooManyRequestsError(_response.error.body, _response.rawResponse);
                    case 498:
                        throw new Cohere.InvalidTokenError(_response.error.body, _response.rawResponse);
                    case 499:
                        throw new Cohere.ClientClosedRequestError(_response.error.body, _response.rawResponse);
                    case 500:
                        throw new Cohere.InternalServerError(_response.error.body, _response.rawResponse);
                    case 501:
                        throw new Cohere.NotImplementedError(_response.error.body, _response.rawResponse);
                    case 503:
                        throw new Cohere.ServiceUnavailableError(_response.error.body, _response.rawResponse);
                    case 504:
                        throw new Cohere.GatewayTimeoutError(_response.error.body, _response.rawResponse);
                    default:
                        throw new errors.CohereError({
                            statusCode: _response.error.statusCode,
                            body: _response.error.body,
                            rawResponse: _response.rawResponse,
                        });
                }
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.CohereError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                        rawResponse: _response.rawResponse,
                    });
                case "timeout":
                    throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/embed-jobs/{id}/cancel.");
                case "unknown":
                    throw new errors.CohereError({
                        message: _response.error.errorMessage,
                        rawResponse: _response.rawResponse,
                    });
            }
        });
    }
    _getAuthorizationHeader() {
        return __awaiter(this, void 0, void 0, function* () {
            var _a;
            const bearer = (_a = (yield core.Supplier.get(this._options.token))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CO_API_KEY;
            if (bearer != null) {
                return `Bearer ${bearer}`;
            }
            return undefined;
        });
    }
}
exports.EmbedJobs = EmbedJobs;
