diff --git a/doc/source/command-objects/project.rst b/doc/source/command-objects/project.rst index ba741d1dc1..0be4e80680 100644 --- a/doc/source/command-objects/project.rst +++ b/doc/source/command-objects/project.rst @@ -58,6 +58,12 @@ Delete an existing project os project delete +.. option:: --domain + + Domain owning :ref:`\ <_project_delete-project>` (name or ID) + + .. versionadded:: 3 + .. _project_delete-project: .. describe:: diff --git a/doc/source/command-objects/user.rst b/doc/source/command-objects/user.rst index 53becf2799..24a2725b7d 100644 --- a/doc/source/command-objects/user.rst +++ b/doc/source/command-objects/user.rst @@ -80,6 +80,14 @@ Delete user os user delete +.. option:: --domain + + Domain owning :ref:`\ <_user_delete-user>` (name or ID) + + .. versionadded:: 3 + +.. _user_delete-user: + .. describe:: User to delete (name or ID) diff --git a/openstackclient/identity/v3/group.py b/openstackclient/identity/v3/group.py index 14838bba57..5d3cf6422a 100644 --- a/openstackclient/identity/v3/group.py +++ b/openstackclient/identity/v3/group.py @@ -169,12 +169,26 @@ class DeleteGroup(command.Command): 'group', metavar='', help='Name or ID of group to delete') + parser.add_argument( + '--domain', + metavar='', + help='Domain where group resides (name or ID)', + ) return parser def take_action(self, parsed_args): self.log.debug('take_action(%s)', parsed_args) identity_client = self.app.client_manager.identity - group = utils.find_resource(identity_client.groups, parsed_args.group) + + if parsed_args.domain: + domain = common.find_domain(identity_client, parsed_args.domain) + group = utils.find_resource(identity_client.groups, + parsed_args.group, + domain_id=domain.id) + else: + group = utils.find_resource(identity_client.groups, + parsed_args.group) + identity_client.groups.delete(group.id) return diff --git a/openstackclient/identity/v3/project.py b/openstackclient/identity/v3/project.py index 3b0e92fd8c..1e3977ba36 100644 --- a/openstackclient/identity/v3/project.py +++ b/openstackclient/identity/v3/project.py @@ -126,16 +126,25 @@ class DeleteProject(command.Command): metavar='', help='Project to delete (name or ID)', ) + parser.add_argument( + '--domain', + metavar='', + help='Domain owning (name or ID)', + ) return parser def take_action(self, parsed_args): self.log.debug('take_action(%s)', parsed_args) identity_client = self.app.client_manager.identity - project = utils.find_resource( - identity_client.projects, - parsed_args.project, - ) + if parsed_args.domain: + domain = common.find_domain(identity_client, parsed_args.domain) + project = utils.find_resource(identity_client.projects, + parsed_args.project, + domain_id=domain.id) + else: + project = utils.find_resource(identity_client.projects, + parsed_args.project) identity_client.projects.delete(project.id) return diff --git a/openstackclient/identity/v3/user.py b/openstackclient/identity/v3/user.py index 10ffce36b8..665dd4bb16 100644 --- a/openstackclient/identity/v3/user.py +++ b/openstackclient/identity/v3/user.py @@ -148,16 +148,25 @@ class DeleteUser(command.Command): metavar='', help='User to delete (name or ID)', ) + parser.add_argument( + '--domain', + metavar='', + help='Domain owning (name or ID)', + ) return parser def take_action(self, parsed_args): self.log.debug('take_action(%s)', parsed_args) identity_client = self.app.client_manager.identity - user = utils.find_resource( - identity_client.users, - parsed_args.user, - ) + if parsed_args.domain: + domain = common.find_domain(identity_client, parsed_args.domain) + user = utils.find_resource(identity_client.users, + parsed_args.user, + domain_id=domain.id) + else: + user = utils.find_resource(identity_client.users, + parsed_args.user) identity_client.users.delete(user.id) return