def Run(self, args): op_refs = args.CONCEPTS.operations.Parse() console_io.PromptContinue(message=command_util.ConstructList( 'Deleting the following operations: ', [ '[%s] in [%s]' % (op_ref.operationsId, op_ref.locationsId) for op_ref in op_refs ]), cancel_on_no=True, cancel_string='Deletion aborted by user.', throw_if_unattended=True) encountered_errors = False for op_ref in op_refs: try: operations_api_util.Delete(op_ref, release_track=self.ReleaseTrack()) failed = None except apitools_exceptions.HttpError as e: exc = exceptions.HttpException(e) failed = exc.payload.status_message encountered_errors = True log.DeletedResource(op_ref.RelativeName(), kind='operation', failed=failed) if encountered_errors: raise command_util.Error('Some deletions did not succeed.')
def Run(self, args): env_refs = args.CONCEPTS.environments.Parse() console_io.PromptContinue(message=command_util.ConstructList( 'Deleting the following environments: ', [ '[{}] in [{}]'.format(env_ref.environmentsId, env_ref.locationsId) for env_ref in env_refs ]), cancel_on_no=True, cancel_string='Deletion aborted by user.', throw_if_unattended=True) waiter = delete_util.EnvironmentDeletionWaiter( release_track=self.ReleaseTrack()) encountered_errors = False for env_ref in env_refs: operation = None failed = None details = None try: operation = environments_api_util.Delete( env_ref, release_track=self.ReleaseTrack()) except apitools_exceptions.HttpError as e: failed = exceptions.HttpException(e).payload.status_message encountered_errors = True else: details = 'with operation [{0}]'.format(operation.name) waiter.AddPendingDelete( environment_name=env_ref.RelativeName(), operation=operation) finally: log.DeletedResource(env_ref.RelativeName(), kind='environment', is_async=True, details=details, failed=failed) if not args.async_: encountered_errors = waiter.Wait() or encountered_errors if encountered_errors: raise command_util.EnvironmentDeleteError( 'Some requested deletions did not succeed. ' 'Please, refer to ' 'https://cloud.google.com/composer/docs/how-to/managing/updating ' 'and Composer Delete Troubleshooting pages to resolve this issue.' )