예제 #1
0
def RemoveRegionFlag(unused_domain_ref, args, patch_request):
  """Removes region from domain."""
  if args.IsSpecified('remove_region'):
    locs = [
        loc for loc in patch_request.domain.locations
        if loc != args.remove_region
    ]
    locs = sorted(set(locs))
    if not locs:
      raise exceptions.ActiveDirectoryError('Cannot remove all regions')
    patch_request.domain.locations = locs
    AddFieldToUpdateMask('locations', patch_request)
  return patch_request
def CheckFieldsSpecified(unused_domain_ref, args, patch_request):
    """Check that update command has one of these flags specified."""
    update_args = [
        'clear_labels',
        'remove_labels',
        'update_labels',
        'add_region',
        'remove_region',
        'add_authorized_networks',
        'remove_authorized_networks',
    ]
    if any(args.IsSpecified(update_arg) for update_arg in update_args):
        return patch_request
    raise exceptions.ActiveDirectoryError(
        'Must specify at least one field to update. Try --help.')
예제 #3
0
  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()))