1# -*- coding: utf-8 -*- # 2# Copyright 2017 Google LLC. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16"""`gcloud iot registries delete` command.""" 17 18from __future__ import absolute_import 19from __future__ import division 20from __future__ import unicode_literals 21 22from googlecloudsdk.api_lib.cloudiot import registries 23from googlecloudsdk.calliope import base 24from googlecloudsdk.command_lib.iot import resource_args 25from googlecloudsdk.core import log 26from googlecloudsdk.core.console import console_io 27 28 29@base.ReleaseTracks(base.ReleaseTrack.BETA, base.ReleaseTrack.GA) 30class Delete(base.DeleteCommand): 31 """Delete a device registry.""" 32 33 detailed_help = { 34 'DESCRIPTION': 35 '{description}', 36 'EXAMPLES': 37 """\ 38 To delete a device registry, run: 39 40 $ {command} my-registry --region=us-central1 41 """, 42 } 43 44 @staticmethod 45 def Args(parser): 46 resource_args.AddRegistryResourceArg(parser, 'to delete') 47 48 def Run(self, args): 49 client = registries.RegistriesClient() 50 registry_ref = args.CONCEPTS.registry.Parse() 51 52 console_io.PromptContinue( 53 'You are about to delete registry [{}]'.format( 54 registry_ref.registriesId), 55 throw_if_unattended=True, cancel_on_no=True) 56 57 response = client.Delete(registry_ref) 58 log.DeletedResource(registry_ref.Name(), 'registry') 59 return response 60