cloudflare
Version:
The official TypeScript library for the Cloudflare API
271 lines (228 loc) • 5.81 kB
text/typescript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../core/resource';
import * as SippyAPI from '../buckets/sippy';
import { APIPromise } from '../../../core/api-promise';
import { RequestOptions } from '../../../internal/request-options';
import { path } from '../../../internal/utils/path';
export class BaseConnectivityPrecheck extends APIResource {
static override readonly _key: readonly ['r2', 'superSlurper', 'connectivityPrecheck'] = Object.freeze([
'r2',
'superSlurper',
'connectivityPrecheck',
] as const);
/**
* Check whether tokens are valid against the source bucket
*
* @example
* ```ts
* const response =
* await client.r2.superSlurper.connectivityPrecheck.source({
* account_id: 'account_id',
* bucket: 'bucket',
* secret: {
* accessKeyId: 'accessKeyId',
* secretAccessKey: 'secretAccessKey',
* },
* vendor: 's3',
* });
* ```
*/
source(
params: ConnectivityPrecheckSourceParams,
options?: RequestOptions,
): APIPromise<ConnectivityPrecheckSourceResponse> {
const { account_id, ...body } = params;
return (
this._client.put(path`/accounts/${account_id}/slurper/source/connectivity-precheck`, {
body,
...options,
}) as APIPromise<{ result: ConnectivityPrecheckSourceResponse }>
)._thenUnwrap((obj) => obj.result);
}
/**
* Check whether tokens are valid against the target bucket
*
* @example
* ```ts
* const response =
* await client.r2.superSlurper.connectivityPrecheck.target({
* account_id: 'account_id',
* bucket: 'bucket',
* secret: {
* accessKeyId: 'accessKeyId',
* secretAccessKey: 'secretAccessKey',
* },
* vendor: 'r2',
* });
* ```
*/
target(
params: ConnectivityPrecheckTargetParams,
options?: RequestOptions,
): APIPromise<ConnectivityPrecheckTargetResponse> {
const { account_id, ...body } = params;
return (
this._client.put(path`/accounts/${account_id}/slurper/target/connectivity-precheck`, {
body,
...options,
}) as APIPromise<{ result: ConnectivityPrecheckTargetResponse }>
)._thenUnwrap((obj) => obj.result);
}
}
export class ConnectivityPrecheck extends BaseConnectivityPrecheck {}
export interface ConnectivityPrecheckSourceResponse {
connectivityStatus?: 'success' | 'error';
}
export interface ConnectivityPrecheckTargetResponse {
connectivityStatus?: 'success' | 'error';
}
export type ConnectivityPrecheckSourceParams =
| ConnectivityPrecheckSourceParams.R2SlurperS3SourceSchema
| ConnectivityPrecheckSourceParams.R2SlurperGcsSourceSchema
| ConnectivityPrecheckSourceParams.R2SlurperR2SourceSchema;
export declare namespace ConnectivityPrecheckSourceParams {
export interface R2SlurperS3SourceSchema {
/**
* Path param
*/
account_id: string;
/**
* Body param
*/
bucket: string;
/**
* Body param
*/
secret: R2SlurperS3SourceSchema.Secret;
/**
* Body param
*/
vendor: 's3';
/**
* Body param: Custom S3-compatible endpoint that must use https://.
*/
endpoint?: string | null;
/**
* Body param
*/
keys?: Array<string> | null;
/**
* Body param
*/
pathPrefix?: string | null;
/**
* Body param
*/
region?: string | null;
}
export namespace R2SlurperS3SourceSchema {
export interface Secret {
accessKeyId: string;
secretAccessKey: string;
}
}
export interface R2SlurperGcsSourceSchema {
/**
* Path param
*/
account_id: string;
/**
* Body param
*/
bucket: string;
/**
* Body param
*/
secret: R2SlurperGcsSourceSchema.Secret;
/**
* Body param
*/
vendor: 'gcs';
/**
* Body param
*/
keys?: Array<string> | null;
/**
* Body param
*/
pathPrefix?: string | null;
}
export namespace R2SlurperGcsSourceSchema {
export interface Secret {
clientEmail: string;
privateKey: string;
}
}
export interface R2SlurperR2SourceSchema {
/**
* Path param
*/
account_id: string;
/**
* Body param
*/
bucket: string;
/**
* Body param
*/
secret: R2SlurperR2SourceSchema.Secret;
/**
* Body param
*/
vendor: SippyAPI.ProviderParam;
/**
* Body param
*/
jurisdiction?: 'default' | 'eu' | 'us' | 'fedramp';
/**
* Body param
*/
keys?: Array<string> | null;
/**
* Body param
*/
pathPrefix?: string | null;
}
export namespace R2SlurperR2SourceSchema {
export interface Secret {
accessKeyId: string;
secretAccessKey: string;
}
}
}
export interface ConnectivityPrecheckTargetParams {
/**
* Path param
*/
account_id: string;
/**
* Body param
*/
bucket: string;
/**
* Body param
*/
secret: ConnectivityPrecheckTargetParams.Secret;
/**
* Body param
*/
vendor: SippyAPI.ProviderParam;
/**
* Body param
*/
jurisdiction?: 'default' | 'eu' | 'us' | 'fedramp';
}
export namespace ConnectivityPrecheckTargetParams {
export interface Secret {
accessKeyId: string;
secretAccessKey: string;
}
}
export declare namespace ConnectivityPrecheck {
export {
type ConnectivityPrecheckSourceResponse as ConnectivityPrecheckSourceResponse,
type ConnectivityPrecheckTargetResponse as ConnectivityPrecheckTargetResponse,
type ConnectivityPrecheckSourceParams as ConnectivityPrecheckSourceParams,
type ConnectivityPrecheckTargetParams as ConnectivityPrecheckTargetParams,
};
}