예제 #1
0
파일: Prices.php 프로젝트: mheydt/scalr
 /**
  * Gets the history of the changes of the specified price
  *
  * @param   string       $platform      The cloud platform
  * @param   string       $cloudLocation The cloud location
  * @param   string       $url           optional The keystone url for the private cloud
  * @param   string       $accountId     optional The identifier of the account for overridden price
  * @return  ArrayCollection Returns collection of the PriceHistoryEntity objects
  */
 public function getHistory($platform, $cloudLocation, $url = null, $accountId = null)
 {
     $accountId = $accountId ?: 0;
     $url = $url ?: '';
     return PriceHistoryEntity::result(PriceHistoryEntity::RESULT_ENTITY_COLLECTION)->find([['platform' => $platform], ['cloudLocation' => $cloudLocation], ['url' => $url], ['accountId' => $accountId]], null, ['applied' => true]);
 }
예제 #2
0
파일: Pricing.php 프로젝트: scalr/scalr
 /**
  * Removes prices on the future effective date
  *
  * @param  string   $platform
  * @param  string   $cloudLocation
  * @param  string   $effectiveDate         The date when the prices will be applied
  * @param  string   $url                   optional
  */
 public function xDeleteAction($platform, $cloudLocation, $effectiveDate, $url = '')
 {
     list($curDate, $effectiveDate) = $this->handleEffectiveDate($effectiveDate);
     if ($effectiveDate <= $curDate) {
         throw new OutOfRangeException(sprintf("It is forbidden to remove prices either on the past or ongoing day."));
     }
     $service = $this->getContainer()->analytics->prices;
     $entity = PriceHistoryEntity::findOne([['platform' => $platform], ['url' => $service->normalizeUrl($url) ?: ''], ['cloudLocation' => $cloudLocation], ['applied' => $effectiveDate], ['accountId' => $this->user->getAccountId() ?: 0]]);
     if ($entity !== null) {
         $cadb = $this->getContainer()->cadb;
         try {
             $cadb->BeginTrans();
             $cadb->Execute("DELETE FROM `prices` WHERE `price_id` = " . $entity->qstr('priceId', $entity->priceId));
             $entity->delete();
             $cadb->CommitTrans();
         } catch (Exception $e) {
             $cadb->RollbackTrans();
             $this->response->failure(sprintf("Database error"));
             return;
         }
         $this->response->success('Prices have been successfully removed');
         return;
     }
     throw new NotFoundException("Could not find any price with specified parameters");
 }
예제 #3
0
파일: Prices.php 프로젝트: rickb838/scalr
 /**
  * Gets the history of the changes of the specified price
  *
  * @param   string       $platform      The cloud platform
  * @param   string       $cloudLocation The cloud location
  * @param   string       $url           optional The keystone url for the private cloud
  * @param   string       $accountId     optional The identifier of the account for overridden price
  * @return  \ArrayObject Returns collection of the PriceHistoryEntity objects
  */
 public function getHistory($platform, $cloudLocation, $url = null, $accountId = null)
 {
     $accountId = $accountId ?: 0;
     $url = $url ?: '';
     return PriceHistoryEntity::find([['platform' => $platform], ['cloudLocation' => $cloudLocation], ['url' => $url], ['accountId' => $accountId]], ['applied' => true]);
 }