export type RESTScanSchedule = {schedule: string, interval: number}; export type RESTAWSAccountKeyConfig = {id?: string | undefined, access_key_id?: string | undefined, secret_access_key?: string | undefined, region?: string | undefined}; export type RESTJfrogXrayConfig = {url?: string | undefined, enable?: boolean | undefined, username?: string | undefined, password?: string | undefined}; export type RESTGCRKeyConfig = {json_key?: string | undefined}; export type RESTRegistryConfig = {name: string, registry_type: string, registry?: string | undefined, filters?: Array | undefined, username?: string | undefined, password?: string | undefined, auth_token?: string | undefined, auth_with_token?: boolean | undefined, rescan_after_db_update?: boolean | undefined, scan_layers?: boolean | undefined, repo_limit?: number | undefined, tag_limit?: number | undefined, schedule?: RESTScanSchedule | undefined, aws_key?: RESTAWSAccountKeyConfig | undefined, jfrog_xray?: RESTJfrogXrayConfig | undefined, gcr_key?: RESTGCRKeyConfig | undefined, jfrog_mode?: string | undefined, jfrog_aql?: boolean | undefined, gitlab_external_url?: string | undefined, gitlab_private_token?: string | undefined, ibm_cloud_token_url?: string | undefined, ibm_cloud_account?: string | undefined}; export type RESTRegistryConfigData = {config: RESTRegistryConfig}; export type PatchApiScanRegistryNameArgs = {'X-Auth-Token': string, name: string, body: RESTRegistryConfigData}; export type PatchApiScanRegistryNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update registry * * PATCH /scan/registry/{name} */ export const patchApiScanRegistryName = async (args: PatchApiScanRegistryNameArgs, options: PatchApiScanRegistryNameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Auth-Token'] != null) headers.set("X-Auth-Token", String(args['X-Auth-Token'])) const url = `${baseUrl.replace(/\/+$/, '')}/scan/registry/${encodeURIComponent(String(args.name))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };