"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
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());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.postByOwnerAndRepoAndRun_id = postByOwnerAndRepoAndRun_id;
var PlainFetcher_1 = require("@nestia/fetcher/lib/PlainFetcher");
var typia_1 = __importDefault(require("typia"));
var NestiaSimulator_1 = require("@nestia/fetcher/lib/NestiaSimulator");
/**
 * Review custom deployment protection rules for a workflow run.
 * Approve or reject custom deployment protection rules provided by a GitHub App for a workflow run. For more information, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)."
 *
 * > [!NOTE]
 * > GitHub Apps can only review their own custom deployment protection rules. To approve or reject pending deployments that are waiting for review from a specific person or team, see [`POST /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments`](/rest/actions/workflow-runs#review-pending-deployments-for-a-workflow-run).
 *
 * OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
 *
 * @tag actions
 * @path repos/:owner/:repo/actions/runs/:run_id/deployment_protection_rule
 * @nestia Generated by Nestia - https://github.com/samchon/nestia
 */
function postByOwnerAndRepoAndRun_id(connection, owner, repo, run_id, body) {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            return [2 /*return*/, !!connection.simulate
                    ? postByOwnerAndRepoAndRun_id.simulate(connection, owner, repo, run_id, body)
                    : PlainFetcher_1.PlainFetcher.fetch(__assign(__assign({}, connection), { headers: __assign(__assign({}, connection.headers), { "Content-Type": "application/json" }) }), __assign(__assign({}, postByOwnerAndRepoAndRun_id.METADATA), { path: postByOwnerAndRepoAndRun_id.path(owner, repo, run_id), status: null }), body)];
        });
    });
}
(function (postByOwnerAndRepoAndRun_id) {
    postByOwnerAndRepoAndRun_id.METADATA = {
        method: "POST",
        path: "/repos/:owner/:repo/actions/runs/:run_id/deployment_protection_rule",
        request: {
            type: "application/json",
            encrypted: false,
        },
        response: {
            type: "application/json",
            encrypted: false,
        },
    };
    postByOwnerAndRepoAndRun_id.path = function (owner, repo, run_id) {
        return "/repos/".concat(encodeURIComponent(owner !== null && owner !== void 0 ? owner : "null"), "/").concat(encodeURIComponent(repo !== null && repo !== void 0 ? repo : "null"), "/actions/runs/").concat(encodeURIComponent(run_id !== null && run_id !== void 0 ? run_id : "null"), "/deployment_protection_rule");
    };
    postByOwnerAndRepoAndRun_id.random = function (g) { return (function () { var _generator; return function (generator) {
        _generator = generator;
        return undefined;
    }; })()(g); };
    postByOwnerAndRepoAndRun_id.simulate = function (connection, owner, repo, run_id, body) {
        var assert = NestiaSimulator_1.NestiaSimulator.assert({
            method: postByOwnerAndRepoAndRun_id.METADATA.method,
            host: connection.host,
            path: postByOwnerAndRepoAndRun_id.path(owner, repo, run_id),
            contentType: "application/json",
        });
        try {
            assert.param("owner")(function () { return (function () { var $guard = typia_1.default.assert.guard; var __is = function (input) { return "string" === typeof input; }; var _errorFactory; return function (input, errorFactory) {
                if (false === __is(input)) {
                    _errorFactory = errorFactory;
                    (function (input, _path, _exceptionable) {
                        if (_exceptionable === void 0) { _exceptionable = true; }
                        return "string" === typeof input || $guard(true, {
                            path: _path + "",
                            expected: "string",
                            value: input
                        }, _errorFactory);
                    })(input, "$input", true);
                }
                return input;
            }; })()(owner); });
            assert.param("repo")(function () { return (function () { var $guard = typia_1.default.assert.guard; var __is = function (input) { return "string" === typeof input; }; var _errorFactory; return function (input, errorFactory) {
                if (false === __is(input)) {
                    _errorFactory = errorFactory;
                    (function (input, _path, _exceptionable) {
                        if (_exceptionable === void 0) { _exceptionable = true; }
                        return "string" === typeof input || $guard(true, {
                            path: _path + "",
                            expected: "string",
                            value: input
                        }, _errorFactory);
                    })(input, "$input", true);
                }
                return input;
            }; })()(repo); });
            assert.param("run_id")(function () { return (function () { var $guard = typia_1.default.assert.guard; var __is = function (input) { return "string" === typeof input; }; var _errorFactory; return function (input, errorFactory) {
                if (false === __is(input)) {
                    _errorFactory = errorFactory;
                    (function (input, _path, _exceptionable) {
                        if (_exceptionable === void 0) { _exceptionable = true; }
                        return "string" === typeof input || $guard(true, {
                            path: _path + "",
                            expected: "string",
                            value: input
                        }, _errorFactory);
                    })(input, "$input", true);
                }
                return input;
            }; })()(run_id); });
            assert.body(function () { return (function () { var $guard = typia_1.default.assert.guard; var $io0 = function (input) { return "string" === typeof input.environment_name && "string" === typeof input.comment; }; var $io1 = function (input) { return "string" === typeof input.environment_name && ("approved" === input.state || "rejected" === input.state) && (undefined === input.comment || "string" === typeof input.comment); }; var $iu0 = function (input) { return (function () {
                if (undefined !== input.state)
                    return $io1(input);
                else
                    return $io0(input);
            })(); }; var $ao0 = function (input, _path, _exceptionable) {
                if (_exceptionable === void 0) { _exceptionable = true; }
                return ("string" === typeof input.environment_name || $guard(_exceptionable, {
                    path: _path + ".environment_name",
                    expected: "string",
                    value: input.environment_name
                }, _errorFactory)) && ("string" === typeof input.comment || $guard(_exceptionable, {
                    path: _path + ".comment",
                    expected: "string",
                    value: input.comment
                }, _errorFactory));
            }; var $ao1 = function (input, _path, _exceptionable) {
                if (_exceptionable === void 0) { _exceptionable = true; }
                return ("string" === typeof input.environment_name || $guard(_exceptionable, {
                    path: _path + ".environment_name",
                    expected: "string",
                    value: input.environment_name
                }, _errorFactory)) && ("approved" === input.state || "rejected" === input.state || $guard(_exceptionable, {
                    path: _path + ".state",
                    expected: "(\"approved\" | \"rejected\")",
                    value: input.state
                }, _errorFactory)) && (undefined === input.comment || "string" === typeof input.comment || $guard(_exceptionable, {
                    path: _path + ".comment",
                    expected: "(string | undefined)",
                    value: input.comment
                }, _errorFactory));
            }; var $au0 = function (input, _path, _exceptionable) {
                if (_exceptionable === void 0) { _exceptionable = true; }
                return (function () {
                    if (undefined !== input.state)
                        return $ao1(input, _path, true && _exceptionable);
                    else
                        return $ao0(input, _path, true && _exceptionable);
                })();
            }; var __is = function (input) { return "object" === typeof input && null !== input && $iu0(input); }; var _errorFactory; return function (input, errorFactory) {
                if (false === __is(input)) {
                    _errorFactory = errorFactory;
                    (function (input, _path, _exceptionable) {
                        if (_exceptionable === void 0) { _exceptionable = true; }
                        return ("object" === typeof input && null !== input || $guard(true, {
                            path: _path + "",
                            expected: "(review_minus_custom_minus_gates_minus_comment_minus_required | review_minus_custom_minus_gates_minus_state_minus_required)",
                            value: input
                        }, _errorFactory)) && $au0(input, _path + "", true) || $guard(true, {
                            path: _path + "",
                            expected: "(review_minus_custom_minus_gates_minus_comment_minus_required | review_minus_custom_minus_gates_minus_state_minus_required)",
                            value: input
                        }, _errorFactory);
                    })(input, "$input", true);
                }
                return input;
            }; })()(body); });
        }
        catch (exp) {
            if (!(function () { var $io0 = function (input) { return ("HEAD" === input.method || "GET" === input.method || "DELETE" === input.method || "POST" === input.method || "PUT" === input.method || "PATCH" === input.method) && "string" === typeof input.path && "number" === typeof input.status && ("object" === typeof input.headers && null !== input.headers && false === Array.isArray(input.headers) && $io1(input.headers)) && "string" === typeof input.name && "string" === typeof input.message && (undefined === input.stack || "string" === typeof input.stack); }; var $io1 = function (input) { return Object.keys(input).every(function (key) {
                var value = input[key];
                if (undefined === value)
                    return true;
                return null !== value && undefined !== value && ("string" === typeof value || Array.isArray(value) && value.every(function (elem) { return "string" === typeof elem; }));
            }); }; return function (input) { return "object" === typeof input && null !== input && $io0(input); }; })()(exp))
                throw exp;
            return {
                success: false,
                status: exp.status,
                headers: exp.headers,
                data: exp.toJSON().message,
            };
        }
        return postByOwnerAndRepoAndRun_id.random("object" === typeof connection.simulate && null !== connection.simulate
            ? connection.simulate
            : undefined);
    };
})(postByOwnerAndRepoAndRun_id || (exports.postByOwnerAndRepoAndRun_id = postByOwnerAndRepoAndRun_id = {}));
//# sourceMappingURL=index.js.map