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