1# -*- coding: utf-8 -*- # 2# Copyright 2020 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"""`gcloud domains registrations configure management` command.""" 16 17from __future__ import absolute_import 18from __future__ import division 19from __future__ import unicode_literals 20 21from googlecloudsdk.api_lib.domains import registrations 22from googlecloudsdk.calliope import base 23from googlecloudsdk.command_lib.domains import flags 24from googlecloudsdk.command_lib.domains import resource_args 25from googlecloudsdk.command_lib.domains import util 26from googlecloudsdk.core import log 27 28 29@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA) 30class ConfigureManagement(base.UpdateCommand): 31 """Configure management settings of a Cloud Domains registration. 32 33 Configure management settings of a registration. This includes settings 34 related to transfers, billing and renewals of a registration. 35 36 ## EXAMPLES 37 38 To unlock a transfer lock of a registration for ``example.com'', run: 39 40 $ {command} example.com --transfer-lock-state=unlocked 41 """ 42 43 @staticmethod 44 def Args(parser): 45 resource_args.AddRegistrationResourceArg( 46 parser, 'to configure management settings for') 47 flags.AddManagementSettingsFlagsToParser(parser) 48 flags.AddAsyncFlagToParser(parser) 49 50 def Run(self, args): 51 api_version = registrations.GetApiVersionFromArgs(args) 52 client = registrations.RegistrationsClient(api_version) 53 args.registration = util.NormalizeResourceName(args.registration) 54 registration_ref = args.CONCEPTS.registration.Parse() 55 56 registration = client.Get(registration_ref) 57 util.AssertRegistrationOperational(api_version, registration) 58 59 transfer_lock_state = util.ParseTransferLockState(api_version, 60 args.transfer_lock_state) 61 if transfer_lock_state is None: 62 transfer_lock_state = util.PromptForTransferLockState( 63 api_version, registration.managementSettings.transferLockState) 64 if transfer_lock_state is None: 65 return None 66 67 response = client.ConfigureManagement(registration_ref, transfer_lock_state) 68 69 response = util.WaitForOperation(api_version, response, args.async_) 70 log.UpdatedResource(registration_ref.Name(), 'registration', args.async_) 71 return response 72