// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../../../core/resource';
import { PagePromise, SinglePage } from '../../../../core/pagination';
import { RequestOptions } from '../../../../internal/request-options';
import { path } from '../../../../internal/utils/path';

export class BaseLogs extends APIResource {
  static override readonly _key: readonly ['r2', 'superSlurper', 'jobs', 'logs'] = Object.freeze([
    'r2',
    'superSlurper',
    'jobs',
    'logs',
  ] as const);

  /**
   * Gets log entries for an R2 Super Slurper migration job, showing migration status
   * changes, errors, etc.
   *
   * @example
   * ```ts
   * // Automatically fetches more pages as needed.
   * for await (const logListResponse of client.r2.superSlurper.jobs.logs.list(
   *   'job_id',
   *   { account_id: 'account_id' },
   * )) {
   *   // ...
   * }
   * ```
   */
  list(
    jobID: string,
    params: LogListParams,
    options?: RequestOptions,
  ): PagePromise<LogListResponsesSinglePage, LogListResponse> {
    const { account_id, ...query } = params;
    return this._client.getAPIList(
      path`/accounts/${account_id}/slurper/jobs/${jobID}/logs`,
      SinglePage<LogListResponse>,
      { query, ...options },
    );
  }
}
export class Logs extends BaseLogs {}

export type LogListResponsesSinglePage = SinglePage<LogListResponse>;

export interface LogListResponse {
  createdAt?: string;

  job?: string;

  logType?:
    | 'migrationStart'
    | 'migrationComplete'
    | 'migrationAbort'
    | 'migrationError'
    | 'migrationPause'
    | 'migrationResume'
    | 'migrationErrorFailedContinuation'
    | 'importErrorRetryExhaustion'
    | 'importSkippedStorageClass'
    | 'importSkippedOversized'
    | 'importSkippedEmptyObject'
    | 'importSkippedUnsupportedContentType'
    | 'importSkippedExcludedContentType'
    | 'importSkippedInvalidMedia'
    | 'importSkippedRequiresRetrieval';

  message?: string | null;

  objectKey?: string | null;
}

export interface LogListParams {
  /**
   * Path param
   */
  account_id: string;

  /**
   * Query param
   */
  limit?: number;

  /**
   * Query param
   */
  offset?: number;
}

export declare namespace Logs {
  export {
    type LogListResponse as LogListResponse,
    type LogListResponsesSinglePage as LogListResponsesSinglePage,
    type LogListParams as LogListParams,
  };
}
