export type RegistryCredential = {type?: string | undefined, access_key?: string | undefined, access_secret?: string | undefined}; export type Registry = {id?: number | undefined, url?: string | undefined, name?: string | undefined, credential?: RegistryCredential | undefined, type?: string | undefined, insecure?: boolean | undefined, ca_certificate?: (string | null) | undefined, description?: string | undefined, status?: string | undefined, creation_time?: string | undefined, update_time?: string | undefined}; export type ReplicationTriggerSettings = {cron?: string | undefined}; export type ReplicationTrigger = {type?: string | undefined, trigger_settings?: ReplicationTriggerSettings | undefined}; export type ReplicationFilter = {type?: string | undefined, value: unknown, decoration?: string | undefined}; export type ReplicationPolicy = {id?: number | undefined, name?: string | undefined, description?: string | undefined, src_registry?: Registry | undefined, dest_registry?: Registry | undefined, dest_namespace?: string | undefined, dest_namespace_replace_count?: number | undefined, trigger?: ReplicationTrigger | undefined, filters?: Array | undefined, replicate_deletion?: boolean | undefined, deletion?: boolean | undefined, override?: boolean | undefined, enabled?: boolean | undefined, creation_time?: string | undefined, update_time?: string | undefined, speed?: number | undefined, copy_by_chunk?: boolean | undefined, single_active_replication?: boolean | undefined}; export type UpdateApiReplicationPoliciesIdArgs = {'X-Request-Id'?: string | undefined, id: number, body: ReplicationPolicy}; export type UpdateApiReplicationPoliciesIdOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Update the replication policy * * PUT /replication/policies/{id} */ export const updateApiReplicationPoliciesId = async (args: UpdateApiReplicationPoliciesIdArgs, options?: UpdateApiReplicationPoliciesIdOptions) => { const {baseUrl = "http://localhost/api/v2.0", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Request-Id'] != null) headers.set("X-Request-Id", String(args['X-Request-Id'])) if (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/replication/policies/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };