Skip to content

Commit

Permalink
add command to remove vanity domains (#155)
Browse files Browse the repository at this point in the history
* add command to remove vainty domains

* fix style

* Update VanityDomainDeleteCommand.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
themsaid and taylorotwell authored Oct 28, 2021
1 parent f6614d9 commit c32c8fb
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/Commands/VanityDomainDeleteCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Laravel\VaporCli\Commands;

use Laravel\VaporCli\Helpers;
use Laravel\VaporCli\Manifest;
use Symfony\Component\Console\Input\InputArgument;

class VanityDomainDeleteCommand extends Command
{
/**
* Configure the command options.
*
* @return void
*/
protected function configure()
{
$this
->setName('vanity-domain:delete')
->addArgument('environment', InputArgument::REQUIRED, 'The environment name')
->setDescription('Delete the vanity domain associated with the given environment');
}

/**
* Execute the command.
*
* @return void
*/
public function handle()
{
$environment = $this->argument('environment');

if (! Helpers::confirm("Are you sure you want to delete the vanity domain of the [{$environment}] environment", false)) {
Helpers::abort('Action cancelled.');
}

$this->vapor->deleteVanityDomain(
Manifest::id(),
$environment
);

Helpers::info('Vanity domain deletion initiated successfully.');
Helpers::line();
Helpers::line('The process may take several seconds to complete.');
}
}
15 changes: 15 additions & 0 deletions src/ConsoleVaporClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,21 @@ public function deleteEnvironment($projectId, $environment)
);
}

/**
* Delete the vanity domain of given environment.
*
* @param string $projectId
* @param string $environment
* @return void
*/
public function deleteVanityDomain($projectId, $environment)
{
return $this->requestWithErrorHandling(
'delete',
'api/projects/'.$projectId.'/environments/'.$environment.'/vanity-domain'
);
}

/**
* Get all of the secrets for the given environment.
*
Expand Down
3 changes: 3 additions & 0 deletions vapor
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ $app->add(new Commands\EnvCloneCommand);
$app->add(new Commands\EnvDeleteCommand);
$app->add(new Commands\OpenCommand);

// Vanity Domains...
$app->add(new Commands\VanityDomainDeleteCommand);

// Secrets
$app->add(new Commands\SecretListCommand);
$app->add(new Commands\SecretCommand);
Expand Down

0 comments on commit c32c8fb

Please sign in to comment.