Exemplo 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')
Exemplo n.º 2
0
 def testParseBillingAccount(self):
     args = self.parser.parse_args(['--billing-account', BILLING_ACCOUNT])
     self.assertEqual(args.billing_account, BILLING_ACCOUNT)
     list_request = flag_utils.GetListRequestFromArgs(
         args, BILLING_ACCOUNT_PARENT_RESOURCE, is_insight_api=False)
     self.assertEqual(list_request,
                      BILLING_ACCOUNT_LIST_RECOMMENDATION_REQUEST)
Exemplo n.º 3
0
 def testParseOrganization(self):
     args = self.parser.parse_args(['--organization', ORGANIZATION])
     self.assertEqual(args.organization, ORGANIZATION)
     list_request = flag_utils.GetListRequestFromArgs(
         args, ORGANIZATION_PARENT_RESOURCE, is_insight_api=False)
     self.assertEqual(list_request,
                      ORGANIZATION_LIST_RECOMMENDATION_REQUEST)
Exemplo n.º 4
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')
Exemplo n.º 5
0
 def testParseFolder(self):
     args = self.parser.parse_args(['--folder', FOLDER])
     self.assertEqual(args.folder, FOLDER)
     list_request = flag_utils.GetListRequestFromArgs(
         args, FOLDER_PARENT_RESOURCE, is_insight_api=False)
     self.assertEqual(list_request, FOLDER_LIST_RECOMMENDATION_REQUEST)
Exemplo n.º 6
0
 def testParseProject(self):
     args = self.parser.parse_args(['--project', PROJECT])
     self.assertEqual(args.project, PROJECT)
     list_request = flag_utils.GetListRequestFromArgs(
         args, PROJECT_PARENT_RESOURCE, is_insight_api=False)
     self.assertEqual(list_request, PROJECT_LIST_RECOMMENDATION_REQUEST)