Esempio n. 1
0
    def Run(self, args):
        """Run 'gcloud recommender insights list'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      The list of insights for this project.
    """
        api_version = api_utils.GetApiVersion(self.ReleaseTrack())
        is_insight_api = True
        is_list_api = True
        recommender_service = api_utils.GetServiceFromArgs(
            args, is_insight_api, api_version)
        parent_ref = flags.GetParentFromFlags(args, is_list_api,
                                              is_insight_api)
        request = api_utils.GetListRequestFromArgs(args, parent_ref,
                                                   is_insight_api, api_version)
        return list_pager.YieldFromList(recommender_service,
                                        request,
                                        batch_size_attribute='pageSize',
                                        batch_size=args.page_size,
                                        limit=args.limit,
                                        field='insights')
Esempio n. 2
0
  def Run(self, args):
    """Run 'gcloud recommender insights mark-accepted'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      The result insights after being marked as accepted
    """
    recommender_service = api_utils.GetServiceFromArgs(
        args, is_insight_api=True)
    parent_ref = flags.GetParentFromFlags(
        args, is_list_api=False, is_insight_api=True)
    request = api_utils.GetMarkAcceptedRequestFromArgs(
        args, parent_ref, is_insight_api=True)
    return recommender_service.MarkAccepted(request)
    def Run(self, args):
        """Run 'gcloud recommender recommendations mark-dismissed'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      The updated recommendation after being marked as dismissed.
    """
        recommender_service = api_utils.GetServiceFromArgs(
            args, is_insight_api=False)
        parent_ref = flags.GetParentFromFlags(args,
                                              is_list_api=False,
                                              is_insight_api=False)
        request = api_utils.GetMarkDismissedRequestFromArgs(
            args, parent_ref, is_insight_api=False)
        return recommender_service.MarkDismissed(request)
Esempio n. 4
0
    def Run(self, args):
        """Run 'gcloud recommender recommendations mark-active'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      The result recommendations after being marked as active
    """
        api_version = api_utils.GetApiVersion(self.ReleaseTrack())
        is_insight_api = False
        is_list_api = False
        recommender_service = api_utils.GetServiceFromArgs(
            args, is_insight_api, api_version)
        parent_ref = flags.GetParentFromFlags(args, is_list_api,
                                              is_insight_api)
        request = api_utils.GetMarkActiveRequestFromArgs(
            args, parent_ref, is_insight_api, api_version)
        return recommender_service.MarkActive(request)
Esempio n. 5
0
    def Run(self, args):
        """Run 'gcloud recommender insights describe'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      The result insights to describe
    """
        api_version = api_utils.GetApiVersion(self.ReleaseTrack())
        is_insight_api = True
        is_list_api = False
        recommender_service = api_utils.GetServiceFromArgs(
            args, is_insight_api, api_version)
        parent_ref = flags.GetParentFromFlags(args, is_list_api,
                                              is_insight_api)
        request = api_utils.GetDescribeRequestFromArgs(args, parent_ref,
                                                       is_insight_api,
                                                       api_version)
        return recommender_service.Get(request)
Esempio n. 6
0
    def Run(self, args):
        """Run 'gcloud recommender recommendations list'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      The list of recommendations for this project.
    """
        recommender_service = api_utils.GetServiceFromArgs(
            args, is_insight_api=False)
        parent_ref = flags.GetParentFromFlags(args,
                                              is_list_api=True,
                                              is_insight_api=False)
        request = api_utils.GetListRequestFromArgs(args,
                                                   parent_ref,
                                                   is_insight_api=False)
        return list_pager.YieldFromList(recommender_service,
                                        request,
                                        batch_size_attribute='pageSize',
                                        batch_size=args.page_size,
                                        limit=args.limit,
                                        field='recommendations')