Ejemplo 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')
def CreateClient(release_track):
    """Creates Client.

  Args:
    release_track: release_track value, can be ALPHA, BETA, GA

  Returns:
    The versioned client.
  """
    api_version = flag_utils.GetApiVersion(release_track)
    return Recommendation(api_version)
Ejemplo n.º 3
0
    def Run(self, args):
        """Run 'gcloud recommender recommenderConfigs describe'.

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

    Returns:
      The result recommender config to describe.
    """
        api_version = api_utils.GetApiVersion(self.ReleaseTrack())
        is_insight_api = False
        recommender_service = api_utils.GetConfigServiceFromArgs(
            api_version, is_insight_api)
        parent_ref = flags.GetConfigsParentFromFlags(args, is_insight_api)
        request = api_utils.GetDescribeConfigRequestFromArgs(
            parent_ref, is_insight_api, api_version)
        return recommender_service.GetConfig(request)
Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 6
0
def CreateClient(release_track):
    """Creates Client."""
    api_version = flag_utils.GetApiVersion(release_track)
    return Insight(api_version)
Ejemplo n.º 7
0
def CreateClient(release_track):
    """Creates Client."""
    api_version = flag_utils.GetApiVersion(release_track)
    return RecommenderConfig(api_version)