summaryrefslogtreecommitdiff
path: root/barbicanclient/barbican_cli/v1/secrets.py
diff options
context:
space:
mode:
authorMauricio Harley <mharley@redhat.com>2022-11-24 10:50:27 +0100
committerAndre Aranha <afariasa@redhat.com>2023-02-07 13:50:51 +0100
commit7f6b3cf790e7d37e85fb38d300fb43573f31184c (patch)
treea89292f06044ac6a5368d8261e015900b0864536 /barbicanclient/barbican_cli/v1/secrets.py
parent3ffa1600af21620d7f141faee9389c7e7e9079e3 (diff)
downloadpython-barbicanclient-7f6b3cf790e7d37e85fb38d300fb43573f31184c.tar.gz
Added the force parameter to consumer removal and the corresponding CLI commands
When deleting a secret that has consumers, the --force parameter must be specified in the CLI. Change-Id: I49d19ac843d5c805fd7f533d07a3a719ce9a1104
Diffstat (limited to 'barbicanclient/barbican_cli/v1/secrets.py')
-rw-r--r--barbicanclient/barbican_cli/v1/secrets.py56
1 files changed, 55 insertions, 1 deletions
diff --git a/barbicanclient/barbican_cli/v1/secrets.py b/barbicanclient/barbican_cli/v1/secrets.py
index 65d94ad..3ce2348 100644
--- a/barbicanclient/barbican_cli/v1/secrets.py
+++ b/barbicanclient/barbican_cli/v1/secrets.py
@@ -28,10 +28,16 @@ class DeleteSecret(command.Command):
def get_parser(self, prog_name):
parser = super(DeleteSecret, self).get_parser(prog_name)
parser.add_argument('URI', help='The URI reference for the secret')
+ parser.add_argument('--force', '-f',
+ default=False,
+ help='if specified, forces the '
+ 'deletion of secrets that have consumers.',
+ action='store_true')
return parser
def take_action(self, args):
- self.app.client_manager.key_manager.secrets.delete(args.URI)
+ self.app.client_manager.key_manager.secrets.delete(
+ args.URI, args.force)
class GetSecret(show.ShowOne):
@@ -198,3 +204,51 @@ class StoreSecret(show.ShowOne):
secret_type=args.secret_type)
entity.store()
return entity._get_formatted_entity()
+
+
+class CreateConsumer(command.Command):
+ """Create a consumer for a secret."""
+
+ def get_parser(self, prog_name):
+ parser = super(CreateConsumer, self).get_parser(prog_name)
+ parser.add_argument('URI', help='The URI reference for the secret')
+ parser.add_argument('--service-type-name', '-s', required=True,
+ help='the service that will consume the secret')
+ parser.add_argument('--resource-type', '-t', required=True,
+ help='the type of resource that will consume '
+ 'the secret')
+ parser.add_argument('--resource-id', '-i', required=True,
+ help='the id of the resource that will consume '
+ 'the secret')
+ return parser
+
+ def take_action(self, args):
+ self.app.client_manager.key_manager.secrets.register_consumer(
+ args.URI,
+ args.service_type_name,
+ args.resource_type,
+ args.resource_id)
+
+
+class DeleteConsumer(command.Command):
+ """Delete a consumer from a secret."""
+
+ def get_parser(self, prog_name):
+ parser = super(DeleteConsumer, self).get_parser(prog_name)
+ parser.add_argument('URI', help='The URI reference for the secret')
+ parser.add_argument('--service-type-name', '-s', required=True,
+ help='the service that is consuming the secret')
+ parser.add_argument('--resource-type', '-t', required=True,
+ help='the type of resource that is consuming '
+ 'the secret')
+ parser.add_argument('--resource-id', '-i', required=True,
+ help='the id of the resource that is consuming '
+ 'the secret')
+ return parser
+
+ def take_action(self, args):
+ self.app.client_manager.key_manager.secrets.remove_consumer(
+ args.URI,
+ args.service_type_name,
+ args.resource_type,
+ args.resource_id)