"use strict";
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;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.leaveGrant = exports.declineGrant = exports.acceptGrant = exports.listGrants = exports.revokeGrant = exports.invite = exports.listDomainGrants = void 0;
const gate_js_1 = require("./gate.js");
const http = __importStar(require("./http.js"));
/** GET /domains/registrations/{id}/grants — Who has delegated access to this domain (outgoing). */
const listDomainGrants = (client, id) => http.get(client, '/domains/registrations/{id}/grants', { params: { id } });
exports.listDomainGrants = listDomainGrants;
/** POST /domains/registrations/{id}/grants — Invite another customer to manage parts of this domain. */
const invite = async (client, id, body) => {
await (0, gate_js_1.checkGate)(client, 'POST /domains/registrations/{id}/grants', { registrationId: id });
return http.post(client, '/domains/registrations/{id}/grants', { params: { id }, body });
};
exports.invite = invite;
/** DELETE /domains/registrations/{id}/grants/{grant-id} — Revoke delegated access. */
const revokeGrant = async (client, id, grantId) => {
await (0, gate_js_1.checkGate)(client, 'DELETE /domains/registrations/{id}/grants/{grant-id}', { registrationId: id });
return http.del(client, '/domains/registrations/{id}/grants/{grant-id}', { params: { id, 'grant-id': grantId } });
};
exports.revokeGrant = revokeGrant;
/** GET /grants — Domains shared with this account (incoming). */
const listGrants = (client) => http.get(client, '/grants');
exports.listGrants = listGrants;
/** POST /grants/{id}/accept — Accept a delegated-access invite. */
const acceptGrant = (client, id) => http.post(client, '/grants/{id}/accept', { params: { id } });
exports.acceptGrant = acceptGrant;
/** POST /grants/{id}/decline — Decline a delegated-access invite. */
const declineGrant = (client, id) => http.post(client, '/grants/{id}/decline', { params: { id } });
exports.declineGrant = declineGrant;
/** POST /grants/{id}/leave — Walk away from an active grant. */
const leaveGrant = (client, id) => http.post(client, '/grants/{id}/leave', { params: { id } });
exports.leaveGrant = leaveGrant;