import{get as e}from"@clevercloud/client/esm/api/v2/addon.js";import{getZone as r}from"@clevercloud/client/esm/api/v4/product.js";import{sendToApi as i}from"./lib/send-to-api.js";import{ONE_SECOND as o}from"@clevercloud/client/esm/with-cache.js";class d{constructor({apiConfig:e,ownerId:r,addonId:i,providerId:o,signal:d}){this._apiConfig=e,this._ownerId=r,this._addonId=i,this._provider=o,this._realId=null,this._signal=d}getAddon(){return e({id:this._ownerId,addonId:this._addonId}).then(i({apiConfig:this._apiConfig,signal:this._signal,cacheDelay:o}))}getOperator(e){return(r={provider:this._provider,realId:e},Promise.resolve({method:"get",url:`/v4/addon-providers/addon-${r.provider}/addons/${r.realId}`,headers:{Accept:"application/json"}})).then(i({apiConfig:this._apiConfig,signal:this._signal,cacheDelay:o}));var r}getZone(e){return r({zoneName:e}).then(i({apiConfig:this._apiConfig,signal:this._signal,cacheDelay:o}))}async getAddonWithOperatorAndZone(){const e=await this.getAddon();this._realId=e.realId;const[r,i]=await Promise.all([this.getOperator(e.realId),this.getZone(e.region)]);return{rawAddon:e,operator:r,zone:i}}async restartAddon(){return(e={provider:this._provider,realId:this._realId},Promise.resolve({method:"post",url:`/v4/addon-providers/addon-${e.provider}/addons/${e.realId}/reboot`,headers:{Accept:"application/json"}})).then(i({apiConfig:this._apiConfig}));var e}async rebuildAndRestartAddon(){return(e={provider:this._provider,realId:this._realId},Promise.resolve({method:"post",url:`/v4/addon-providers/addon-${e.provider}/addons/${e.realId}/rebuild`,headers:{Accept:"application/json"}})).then(i({apiConfig:this._apiConfig}));var e}}export{d as CcAddonHeaderClient};
//# sourceMappingURL=cc-addon-header.client.js.map
