/**
  * @param $ip
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function deleteDroplet($ip)
 {
     $http = new Client();
     try {
         return $http->delete("https://api.digitalocean.com/v2/droplets/{$ip}", ['headers' => ['Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . Config::get('api_token')]]);
     } catch (\GuzzleHttp\Exception\ClientException $e) {
         return;
     }
 }
Exemplo n.º 2
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  *
  * @throws \Sharks\Support\Exceptions\MissingApiTokenException
  *
  * @return mixed
  */
 private function getToken(InputInterface $input)
 {
     $token = $input->getOption('token');
     if (!is_null($token)) {
         Config::set('api_token', $token);
     } else {
         $token = Config::get('api_token');
     }
     if (is_null($token)) {
         throw new MissingApiTokenException("You need an API Token duh!");
     }
     return $token;
 }