def GetExistingDomain(domain_ref): """Fetch existing AD domain.""" client = util.GetClientForResource(domain_ref) messages = util.GetMessagesForResource(domain_ref) get_req = messages.ManagedidentitiesProjectsLocationsGlobalDomainsGetRequest( name=domain_ref.RelativeName()) return client.projects_locations_global_domains.Get(get_req)
def UpdateLabels(domain_ref, args, patch_request): """Updates labels of domain.""" labels_diff = labels_util.Diff.FromUpdateArgs(args) if labels_diff.MayHaveUpdates(): patch_request = AddFieldToUpdateMask('labels', patch_request) messages = util.GetMessagesForResource(domain_ref) new_labels = labels_diff.Apply(messages.Domain.LabelsValue, patch_request.domain.labels).GetOrNone() if new_labels: patch_request.domain.labels = new_labels return patch_request
def ProcessPfxFile(domain_ref, args, request): """Reads the pfx file into the LDAPSSettings proto and updates the request.""" if args.certificate_pfx_file: if not request.lDAPSSettings: messages = util.GetMessagesForResource(domain_ref) settings = messages.LDAPSSettings() request.lDAPSSettings = settings request.lDAPSSettings.certificatePfx = args.certificate_pfx_file request = AddFieldToUpdateMask('certificatePfx', request) request = AddFieldToUpdateMask('certificatePassword', request) return request
def ProcessPfxFile(domain_ref, args, request): """Reads the pfx file into the LDAPSSettings proto and updates the request.""" log.status.Print( "note: You must be safelisted for the Managed AD LDAPS Alpha in order to use this feature." ) if args.certificate_pfx_file: if not request.lDAPSSettings: messages = util.GetMessagesForResource(domain_ref) settings = messages.LDAPSSettings() request.lDAPSSettings = settings request.lDAPSSettings.certificatePfx = args.certificate_pfx_file request = AddFieldToUpdateMask('certificatePfx', request) request = AddFieldToUpdateMask('certificatePassword', request) return request
def UpdateLabels(backup_ref, args, patch_request): """Updates labels of domain backups.""" if patch_request is None: return None labels_diff = labels_util.Diff.FromUpdateArgs(args) if labels_diff.MayHaveUpdates(): patch_request = AddFieldToUpdateMask('labels', patch_request) messages = util.GetMessagesForResource(backup_ref) new_labels = labels_diff.Apply( messages.Backup.LabelsValue, patch_request.backup.labels).GetOrNone() if new_labels: patch_request.backup.labels = new_labels return patch_request
def Run(self, args): # resource represents the Managed Microsoft AD operation. resource = args.CONCEPTS.name.Parse() client = util.GetClientForResource(resource) messages = util.GetMessagesForResource(resource) get_req = \ messages.ManagedidentitiesProjectsLocationsGlobalOperationsGetRequest( name=resource.RelativeName()) op = client.projects_locations_global_operations.Get(get_req) operation_string = io.StringIO() print_format = display.Displayer(self, args).GetFormat() resource_printer.Print(op, print_format, out=operation_string) if not console_io.PromptContinue( message='{}\nThis operation will be canceled'.format( operation_string.getvalue())): raise exceptions.ActiveDirectoryError('Cancel aborted by user.') cancel_req = \ messages.ManagedidentitiesProjectsLocationsGlobalOperationsCancelRequest( name=resource.RelativeName()) client.projects_locations_global_operations.Cancel(cancel_req) log.status.write('Canceled [{0}].\n'.format(resource.RelativeName()))