"use strict";
// File generated from our OpenAPI spec by Stainless.
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 (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenListResponsesV4PagePaginationArray = exports.Tokens = void 0;
const resource_1 = require("cloudflare/resource");
const core_1 = require("cloudflare/core");
const TokensAPI = __importStar(require("cloudflare/resources/user/tokens/tokens"));
const PermissionGroupsAPI = __importStar(require("cloudflare/resources/user/tokens/permission-groups"));
const ValueAPI = __importStar(require("cloudflare/resources/user/tokens/value"));
const pagination_1 = require("cloudflare/pagination");
class Tokens extends resource_1.APIResource {
    constructor() {
        super(...arguments);
        this.permissionGroups = new PermissionGroupsAPI.PermissionGroups(this._client);
        this.value = new ValueAPI.Value(this._client);
    }
    /**
     * Create a new access token.
     */
    create(body, options) {
        return this._client.post('/user/tokens', { body, ...options })._thenUnwrap((obj) => obj.result);
    }
    /**
     * Update an existing token.
     */
    update(tokenId, body, options) {
        return this._client.put(`/user/tokens/${tokenId}`, { body, ...options })._thenUnwrap((obj) => obj.result);
    }
    list(query = {}, options) {
        if ((0, core_1.isRequestOptions)(query)) {
            return this.list({}, query);
        }
        return this._client.getAPIList('/user/tokens', TokenListResponsesV4PagePaginationArray, {
            query,
            ...options,
        });
    }
    /**
     * Destroy a token.
     */
    delete(tokenId, options) {
        return this._client.delete(`/user/tokens/${tokenId}`, options)._thenUnwrap((obj) => obj.result);
    }
    /**
     * Get information about a specific token.
     */
    get(tokenId, options) {
        return this._client.get(`/user/tokens/${tokenId}`, options)._thenUnwrap((obj) => obj.result);
    }
    /**
     * Test whether a token works.
     */
    verify(options) {
        return this._client.get('/user/tokens/verify', options)._thenUnwrap((obj) => obj.result);
    }
}
exports.Tokens = Tokens;
class TokenListResponsesV4PagePaginationArray extends pagination_1.V4PagePaginationArray {
}
exports.TokenListResponsesV4PagePaginationArray = TokenListResponsesV4PagePaginationArray;
(function (Tokens) {
    Tokens.TokenListResponsesV4PagePaginationArray = TokensAPI.TokenListResponsesV4PagePaginationArray;
    Tokens.PermissionGroups = PermissionGroupsAPI.PermissionGroups;
    Tokens.Value = ValueAPI.Value;
})(Tokens = exports.Tokens || (exports.Tokens = {}));
//# sourceMappingURL=tokens.js.map