// File generated from our OpenAPI spec by Stainless.
import { APIResource } from 'cloudflare/resource';
import { isRequestOptions } from 'cloudflare/core';
import * as TokensAPI from 'cloudflare/resources/user/tokens/tokens';
import * as PermissionGroupsAPI from 'cloudflare/resources/user/tokens/permission-groups';
import * as ValueAPI from 'cloudflare/resources/user/tokens/value';
import { V4PagePaginationArray } from 'cloudflare/pagination';
export class Tokens extends 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 (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);
    }
}
export class TokenListResponsesV4PagePaginationArray extends V4PagePaginationArray {
}
(function (Tokens) {
    Tokens.TokenListResponsesV4PagePaginationArray = TokensAPI.TokenListResponsesV4PagePaginationArray;
    Tokens.PermissionGroups = PermissionGroupsAPI.PermissionGroups;
    Tokens.Value = ValueAPI.Value;
})(Tokens || (Tokens = {}));
//# sourceMappingURL=tokens.mjs.map