export type EndpointIPAMConfig = {IPv4Address?: string | undefined, IPv6Address?: string | undefined, LinkLocalIPs?: Array | undefined} | null; export type EndpointSettings = {IPAMConfig?: EndpointIPAMConfig | undefined, Links?: Array | undefined, MacAddress?: string | undefined, Aliases?: Array | undefined, DriverOpts?: ({[key: string]: string} | null) | undefined, GwPriority?: number | undefined, NetworkID?: string | undefined, EndpointID?: string | undefined, Gateway?: string | undefined, IPAddress?: string | undefined, IPPrefixLen?: number | undefined, IPv6Gateway?: string | undefined, GlobalIPv6Address?: string | undefined, GlobalIPv6PrefixLen?: number | undefined, DNSNames?: Array | undefined}; export type CreateApiNetworksIdConnectArgs = {id: string, body: {Container?: string | undefined, EndpointConfig?: EndpointSettings | undefined}}; export type CreateApiNetworksIdConnectOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Connect a container to a network * * POST /networks/{id}/connect */ export const createApiNetworksIdConnect = async (args: CreateApiNetworksIdConnectArgs, options: CreateApiNetworksIdConnectOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/networks/${encodeURIComponent(String(args.id))}/connect${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };