cloudflare
Version:
The official TypeScript library for the Cloudflare API
68 lines (60 loc) • 2.01 kB
text/typescript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../../core/resource';
import { APIPromise } from '../../../../core/api-promise';
import { RequestOptions } from '../../../../internal/request-options';
import { path } from '../../../../internal/utils/path';
export class BaseManagement extends APIResource {
static override readonly _key: readonly ['zeroTrust', 'tunnels', 'cloudflared', 'management'] =
Object.freeze(['zeroTrust', 'tunnels', 'cloudflared', 'management'] as const);
/**
* Creates a short-lived management token for the requested Tunnel management
* resources, such as streaming logs. Treat the token as a secret.
*
* @example
* ```ts
* const management =
* await client.zeroTrust.tunnels.cloudflared.management.create(
* 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415',
* {
* account_id: '699d98642c564d2e855e9661899b7252',
* resources: ['logs'],
* },
* );
* ```
*/
create(
tunnelID: string,
params: ManagementCreateParams,
options?: RequestOptions,
): APIPromise<ManagementCreateResponse> {
const { account_id, ...body } = params;
return (
this._client.post(path`/accounts/${account_id}/cfd_tunnel/${tunnelID}/management`, {
body,
...options,
}) as APIPromise<{ result: ManagementCreateResponse }>
)._thenUnwrap((obj) => obj.result);
}
}
export class Management extends BaseManagement {}
/**
* The Tunnel Token is used as a mechanism to authenticate the operation of a
* tunnel.
*/
export type ManagementCreateResponse = string;
export interface ManagementCreateParams {
/**
* Path param: Cloudflare account ID
*/
account_id: string;
/**
* Body param
*/
resources: Array<'logs'>;
}
export declare namespace Management {
export {
type ManagementCreateResponse as ManagementCreateResponse,
type ManagementCreateParams as ManagementCreateParams,
};
}