import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsDataLabelingJobsIdArgs = {projectsId: string, locationsId: string, dataLabelingJobsId: string}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsDataLabelingJobsIdOptions = {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 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 }; /** * Gets a DataLabelingJob. * * GET /v1/projects/{projectsId}/locations/{locationsId}/dataLabelingJobs/{dataLabelingJobsId} */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsDataLabelingJobsId = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsDataLabelingJobsIdArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdDataLabelingJobsDataLabelingJobsIdOptions) => { 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 (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/${encodeURIComponent(String(args.dataLabelingJobsId))}${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(googleCloudAiplatformV1DataLabelingJob, await res.json()) };