/** * @param Account $account */ public function removeAccount(Account $account) { $workspaces = new Workspaces($this->getClient()); try { $workspaces->deleteWorkspace($account->getWorkspaceId(), ["async" => true]); } catch (\Keboola\StorageApi\Exception $e) { $this->logException(Logger::DEBUG, $e->getMessage(), $e); } }
/** * @param $tokenInfo * @param string $credentialsType * @param array $buckets * @param bool $allowMoreTime * @param array $loadData * @param string $runId * @return Account\Workspace\Redshift */ public function addAccount($tokenInfo, $credentialsType = "transformations", $buckets = [], $allowMoreTime = true, $loadData = [], $runId = "") { $workspaces = new Workspaces($this->getClient()); try { $workspace = $workspaces->createWorkspace(["backend" => "redshift"]); } catch (\Keboola\StorageApi\Exception $e) { throw new UserException($e->getMessage(), $e); } $account = new Account\Workspace\Redshift(); $account->setType($credentialsType)->setHostname($workspace["connection"]["host"])->setDatabase($workspace["connection"]["database"])->setUser($workspace["connection"]["user"])->setPassword($workspace["connection"]["password"])->setSchema($workspace["connection"]["schema"])->setWorkspaceId($workspace["id"])->setCreated(new \DateTime())->setActive(true)->setTokenId($tokenInfo["id"])->setTokenDesc($tokenInfo["description"])->setTokenOwnerName($tokenInfo["owner"]["name"])->setTokenOwnerId($tokenInfo["owner"]["id"])->setTouch(new \DateTime()); $this->getEntityManager()->persist($account); $this->getEntityManager()->flush(); return $account; }