1# -*- coding: utf-8 -*- # 2# Copyright 2018 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"""Remove Attestor public key command.""" 16 17from __future__ import absolute_import 18from __future__ import division 19from __future__ import unicode_literals 20 21from googlecloudsdk.api_lib.container.binauthz import apis 22from googlecloudsdk.api_lib.container.binauthz import attestors 23from googlecloudsdk.calliope import base 24from googlecloudsdk.command_lib.container.binauthz import flags 25 26 27class Remove(base.Command): 28 r"""Remove a public key from an Attestor. 29 30 ## EXAMPLES 31 32 To remove a public key from the Attestor `my_attestor`: 33 34 $ {command} 0638AADD940361EA2D7F14C58C124F0E663DA097 \ 35 --attestor=my_attestor 36 """ 37 38 @classmethod 39 def Args(cls, parser): 40 flags.AddConcepts( 41 parser, 42 flags.GetAttestorPresentationSpec( 43 required=True, 44 positional=False, 45 group_help=( 46 'The attestor from which the public key should be removed.'), 47 ), 48 ) 49 parser.add_argument( 50 'public_key_id', 51 help='The ID of the public key to remove.') 52 53 def Run(self, args): 54 api_version = apis.GetApiVersion(self.ReleaseTrack()) 55 attestors_client = attestors.Client(api_version) 56 57 attestor_ref = args.CONCEPTS.attestor.Parse() 58 59 attestors_client.RemoveKey(attestor_ref, pubkey_id=args.public_key_id) 60