def ValidateLimitFlag(limit, flag_name='limit'):
    """Validates a limit flag value.

  Args:
    limit: the limit flag value to sanitize.
    flag_name: the name of the limit flag - defaults to limit
  Raises:
    GenomicsError: if the provided limit flag value is negative
  """
    if limit is None:
        return

    if limit < 0:
        raise GenomicsError(
            '--{0} must be a non-negative integer; received: {1}'.format(
                flag_name, limit))
Beispiel #2
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    Returns:
      None
    """
        op = None
        apitools_client = genomics_util.GetGenomicsClient('v2alpha1')
        genomics_messages = genomics_util.GetGenomicsMessages('v2alpha1')

        name, v2 = genomics_util.CanonicalizeOperationName(args.name)
        if v2:
            op = apitools_client.projects_operations.Get(
                genomics_messages.GenomicsProjectsOperationsGetRequest(
                    name=name))
        else:
            apitools_client = genomics_util.GetGenomicsClient()
            genomics_messages = genomics_util.GetGenomicsMessages()
            op = apitools_client.operations.Get(
                genomics_messages.GenomicsOperationsGetRequest(name=name))

        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='%s\n%s' %
            (operation_string.getvalue(), 'This operation will be canceled')):
            raise GenomicsError('Cancel aborted by user.')

        if v2:
            apitools_client.projects_operations.Cancel(
                genomics_messages.GenomicsProjectsOperationsCancelRequest(
                    name=name))
        else:
            apitools_client.operations.Cancel(
                genomics_messages.GenomicsOperationsCancelRequest(name=name))
        log.status.write('Canceled [{0}].\n'.format(name))
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    Returns:
      None
    """
        apitools_client = genomics_util.GetGenomicsClient()
        genomics_messages = genomics_util.GetGenomicsMessages()

        if not (args.name or args.reference_set_id):
            raise GenomicsError(
                'Must specify --name and/or --reference-set-id')

        updated = genomics_messages.ReadGroupSet()
        mask = []
        # TODO(b/26871577): Consider using resource parser here
        if args.name:
            updated.name = args.name
            mask.append('name')
        if args.reference_set_id:
            updated.referenceSetId = args.reference_set_id
            mask.append('referenceSetId')

        request = genomics_messages.GenomicsReadgroupsetsPatchRequest(
            readGroupSet=updated,
            readGroupSetId=str(args.id),
            updateMask=','.join(mask))

        result = apitools_client.readgroupsets.Patch(request)
        name = str(result.id)
        if result.name:
            name += ', name: {0}'.format(result.name)
        if result.referenceSetId:
            name += ', referenceSetId: {0}'.format(result.referenceSetId)
        log.UpdatedResource(name, kind='readgroupset')
        return result
Beispiel #4
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Raises:
      HttpException: An http error response was received while executing api
          request.
      GenomicsError: if canceled by the user.
    Returns:
      None
    """

        apitools_client = genomics_util.GetGenomicsClient()
        genomics_messages = genomics_util.GetGenomicsMessages()

        get_request = genomics_messages.GenomicsVariantsetsGetRequest(
            variantSetId=str(args.variant_set_id))

        variant_set = apitools_client.variantsets.Get(get_request)

        prompt_message = (
            'Deleting variant set {0}: "{1}" will also delete all its contents '
            '(variants, callsets, and calls).').format(args.variant_set_id,
                                                       variant_set.name)

        if not console_io.PromptContinue(message=prompt_message):
            raise GenomicsError('Deletion aborted by user.')

        req = genomics_messages.GenomicsVariantsetsDeleteRequest(
            variantSetId=args.variant_set_id, )

        ret = apitools_client.variantsets.Delete(req)
        log.DeletedResource('{0}: "{1}"'.format(args.variant_set_id,
                                                variant_set.name))
        return ret
Beispiel #5
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    Returns:
      None
    """
        apitools_client = self.context[lib.GENOMICS_APITOOLS_CLIENT_KEY]
        genomics_messages = self.context[lib.GENOMICS_MESSAGES_MODULE_KEY]

        if not (args.name or args.reference_set_id):
            raise GenomicsError(
                'Must specify --name and/or --reference-set-id')

        updated = genomics_messages.ReadGroupSet()
        mask = []
        # TODO(b/26871577): Consider using resource parser here
        if args.name:
            updated.name = args.name
            mask.append('name')
        if args.reference_set_id:
            updated.referenceSetId = args.reference_set_id
            mask.append('referenceSetId')

        request = genomics_messages.GenomicsReadgroupsetsPatchRequest(
            readGroupSet=updated,
            readGroupSetId=str(args.id),
            updateMask=','.join(mask))

        return apitools_client.readgroupsets.Patch(request)