Skip to content

Commit

Permalink
Merge pull request #23 from pagely/ds_check_job_status
Browse files Browse the repository at this point in the history
draft branch for "ssl:le:jobstatus" command
  • Loading branch information
dshelikhov authored May 11, 2021
2 parents 7fc875c + fee6ec0 commit 685d456
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/API/SSL/SSLClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public function getCert($accessToken, $id, $includeChain = false)
return $this->guzzle($this->getBearerTokenMiddleware($accessToken))->get("ssl/certs/{$id}", ['query' => ['includeChain' => $includeChain]]);
}

public function getLetsencryptStatus($accessToken, $id)
{
return $this->guzzle($this->getBearerTokenMiddleware($accessToken))->get("ssl/letsencrypt/status/{$id}");
}

public function listCerts($accessToken, $accountId, $appId, $includeChain = false)
{
return $this->listCertsAsync($accessToken, $accountId, $appId, $includeChain)->wait();
Expand Down
31 changes: 31 additions & 0 deletions src/Command/SSL/LetsencryptJobStatusCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Pagely\AtomicClient\Command\SSL;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class LetsencryptJobStatusCommand extends AbstractSSLCmd
{
protected $commandName = 'ssl:le:jobstatus';

public function configure()
{
parent::configure();
$this->setDescription('Check letsencrypt job status')
->addArgument('id', InputArgument::REQUIRED, 'ID of the letsencrypt job (not jobId)')
;
$this->addOauthOptions();
}

public function execute(InputInterface $input, OutputInterface $output)
{
$r = $this->api->getLetsencryptStatus(
$this->token->token,
$input->getArgument('id')
);
$output->writeln($r->getBody()->getContents());
}
}

4 changes: 2 additions & 2 deletions src/Command/SSL/LetsencryptRegisterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function execute(InputInterface $input, OutputInterface $output)
);
if ($r->getStatusCode() === 200) {
$data = json_decode($r->getBody()->getContents());
$output->writeln('Successfully queued job: '.$data->jobId);
$output->writeln('Check status at: https://mgmt.pagely.com/api/ssl/letsencrypt/status/'.$data->jobId);
$output->writeln('Successfully queued job: '.$data->id);
$output->writeln('Check status with: atomic ssl:le:jobstatus '.$data->id);
} else {
$output->writeln('<error>Registration failed</error>');
$output->writeln($r->getBody()->getContents());
Expand Down

0 comments on commit 685d456

Please sign in to comment.