import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsArgs = {projectsId: string, locationsId: string, filter?: string | undefined, orderBy?: string | undefined, pageSize?: number | undefined, pageToken?: string | undefined, readMask?: unknown | undefined}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudAiplatformV1SampleConfig = z.object({followingBatchSamplePercentage: z.number().int().optional(), initialBatchSamplePercentage: z.number().int().optional(), sampleStrategy: z.enum(["SAMPLE_STRATEGY_UNSPECIFIED", "UNCERTAINTY"]).optional()}); export const googleCloudAiplatformV1TrainingConfig = z.object({timeoutTrainingMilliHours: z.string().optional()}); export const googleCloudAiplatformV1ActiveLearningConfig = z.object({maxDataItemCount: z.string().optional(), maxDataItemPercentage: z.number().int().optional(), sampleConfig: googleCloudAiplatformV1SampleConfig.optional(), trainingConfig: googleCloudAiplatformV1TrainingConfig.optional()}); export const googleTypeMoney = z.object({currencyCode: z.string().optional(), nanos: z.number().int().optional(), units: z.string().optional()}); export const googleCloudAiplatformV1EncryptionSpec = z.object({kmsKeyName: z.string().optional()}); export const googleRpcStatus = z.object({code: z.number().int().optional(), details: z.array(z.record(z.string(), z.unknown())).optional(), message: z.string().optional()}); export const googleCloudAiplatformV1DataLabelingJob = z.object({activeLearningConfig: googleCloudAiplatformV1ActiveLearningConfig.optional(), annotationLabels: z.record(z.string(), z.string()).optional(), createTime: z.string().optional(), currentSpend: googleTypeMoney.optional(), datasets: z.array(z.string()).optional(), displayName: z.string().optional(), encryptionSpec: googleCloudAiplatformV1EncryptionSpec.optional(), error: googleRpcStatus.optional(), inputs: z.unknown(), inputsSchemaUri: z.string().optional(), instructionUri: z.string().optional(), labelerCount: z.number().int().optional(), labelingProgress: z.number().int().optional(), labels: z.record(z.string(), z.string()).optional(), name: z.string().optional(), specialistPools: z.array(z.string()).optional(), state: z.enum(["JOB_STATE_UNSPECIFIED", "JOB_STATE_QUEUED", "JOB_STATE_PENDING", "JOB_STATE_RUNNING", "JOB_STATE_SUCCEEDED", "JOB_STATE_FAILED", "JOB_STATE_CANCELLING", "JOB_STATE_CANCELLED", "JOB_STATE_PAUSED", "JOB_STATE_EXPIRED", "JOB_STATE_UPDATING", "JOB_STATE_PARTIALLY_SUCCEEDED"]).optional(), updateTime: z.string().optional()}); export const googleCloudAiplatformV1ListDataLabelingJobsResponse = z.object({dataLabelingJobs: z.array(googleCloudAiplatformV1DataLabelingJob).optional(), nextPageToken: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Lists DataLabelingJobs in a Location. * * GET /v1/projects/{projectsId}/locations/{locationsId}/dataLabelingJobs */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobs = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsOptions) => { const {baseUrl = "https://aiplatform.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.filter != null) query.append("filter", String(args.filter)) if (args.orderBy != null) query.append("orderBy", String(args.orderBy)) if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.pageToken != null) query.append("pageToken", String(args.pageToken)) if (args.readMask != null) query.append("readMask", String(args.readMask)) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/projects/${encodeURIComponent(String(args.projectsId))}/locations/${encodeURIComponent(String(args.locationsId))}/dataLabelingJobs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(googleCloudAiplatformV1ListDataLabelingJobsResponse, await res.json()) };