import{v as s,bf as p,a5 as k}from"./index-BTX30BGB.js";const u=e=>new Promise((t,n)=>{fetch(`/1.0/networks?project=${e}&recursion=1`).then(s).then(r=>{const a=r.metadata.filter(c=>!["loopback","unknown"].includes(c.type));t(a)}).catch(n)}),i=(e,t)=>new Promise((n,r)=>{fetch(`/1.0/networks/${e}?project=${t}`).then(k).then(a=>n(a)).catch(r)}),$=(e,t)=>new Promise((n,r)=>{fetch(`/1.0/networks/${e}/state?project=${t}`).then(s).then(a=>n(a.metadata)).catch(r)}),P=(e,t,n)=>new Promise((r,a)=>{var o;const c={name:e.name,description:e.description,type:e.type,config:{parent:(o=e.config)==null?void 0:o.parent}};Promise.allSettled(n.map(async h=>{await d(c,t,h.server_name)})).then(h=>{var w,m;const f=(w=h.find(l=>l.status==="rejected"))==null?void 0:w.reason;if(f){a(f);return}(m=e.config)==null||delete m.parent,d(e,t).then(r).catch(a)}).catch(a)}),d=(e,t,n)=>new Promise((r,a)=>{const c=n?`&target=${n}`:"";fetch(`/1.0/networks?project=${t}${c}`,{method:"POST",body:JSON.stringify(e)}).then(s).then(r).catch(async o=>{o.message==="Failed to fetch"&&await i(e.name??"",t)&&r(),a(o)})}),g=(e,t)=>new Promise((n,r)=>{fetch(`/1.0/networks/${e.name??""}?project=${t}`,{method:"PUT",body:JSON.stringify(e),headers:{"If-Match":e.etag??"invalid-etag"}}).then(s).then(n).catch(async a=>{if(a.message==="Failed to fetch"){const c=await i(e.name??"",t);p(e,c)&&n()}r(a)})}),y=(e,t,n)=>new Promise((r,a)=>{fetch(`/1.0/networks/${e}?project=${n}`,{method:"POST",body:JSON.stringify({name:t})}).then(s).then(r).catch(async c=>{c.message==="Failed to fetch"&&await i(t,n)&&r(),a(c)})}),S=(e,t)=>new Promise((n,r)=>{fetch(`/1.0/networks/${e}?project=${t}`,{method:"DELETE"}).then(s).then(n).catch(async a=>{a.message==="Failed to fetch"&&(await fetch(`/1.0/networks/${e}?project=${t}`)).status===404&&n(),r(a)})}),b=e=>new Promise((t,n)=>{fetch(`/1.0/network-acls?project=${e}&recursion=1`).then(s).then(r=>t(r.metadata)).catch(n)}),O=(e,t)=>new Promise((n,r)=>{fetch(`/1.0/network-acls/${e}?project=${t}`).then(k).then(a=>n(a)).catch(r)}),j=(e,t)=>new Promise((n,r)=>{fetch(`/1.0/network-acls?project=${t}`,{method:"POST",body:JSON.stringify(e)}).then(s).then(n).catch(r)}),E=(e,t)=>new Promise((n,r)=>{fetch(`/1.0/network-acls/${e.name??""}?project=${t}`,{method:"PUT",body:JSON.stringify(e),headers:{"If-Match":e.etag??"invalid-etag"}}).then(s).then(n).catch(r)}),T=(e,t,n)=>new Promise((r,a)=>{fetch(`/1.0/network-acls/${e}?project=${n}`,{method:"POST",body:JSON.stringify({name:t})}).then(s).then(r).catch(a)}),A=(e,t)=>new Promise((n,r)=>{fetch(`/1.0/network-acls/${e}?project=${t}`,{method:"DELETE"}).then(s).then(n).catch(r)});export{d as a,j as b,P as c,i as d,g as e,O as f,S as g,$ as h,u as i,A as j,T as k,b as l,y as r,E as u};
