示例#1
0
def _monitoring_resource_types_list(args, _):
    """Lists the resource descriptors in the project."""
    project_id = args['project']
    pattern = args['type'] or '*'
    descriptors = gcm.ResourceDescriptors(context=_make_context(project_id))
    dataframe = descriptors.as_dataframe(pattern=pattern)
    return _render_dataframe(dataframe)
示例#2
0
 def test_constructor_minimal(self, mock_context_default):
     mock_context_default.return_value = self.context
     descriptors = gcm.ResourceDescriptors()
     self.assertEqual(descriptors._client.project, DEFAULT_PROJECT)
     self.assertEqual(descriptors._client.connection.credentials,
                      self.context.credentials)
     self.assertIsNone(descriptors._filter_string)
     self.assertIsNone(descriptors._descriptors)
示例#3
0
    def test_constructor_maximal(self):
        context = self._create_context(PROJECT)
        descriptors = gcm.ResourceDescriptors(filter_string=FILTER_STRING,
                                              context=context)
        self.assertEqual(descriptors._client.project, PROJECT)

        self.assertEqual(descriptors._filter_string, FILTER_STRING)
        self.assertIsNone(descriptors._descriptors)
示例#4
0
    def test_list_w_api_filter(self, mock_api_list_descriptors):
        mock_api_list_descriptors.return_value = self._list_resources_get_result(
        )

        descriptors = gcm.ResourceDescriptors(filter_string=FILTER_STRING,
                                              context=self.context)
        resource_descriptor_list = descriptors.list()

        mock_api_list_descriptors.assert_called_once_with(
            filter_string=FILTER_STRING)
        self.assertEqual(len(resource_descriptor_list), 2)
        self.assertEqual(resource_descriptor_list[0].type, RESOURCE_TYPES[0])
        self.assertEqual(resource_descriptor_list[1].type, RESOURCE_TYPES[1])
示例#5
0
 def setUp(self):
     self.context = self._create_context(DEFAULT_PROJECT)
     self.descriptors = gcm.ResourceDescriptors(context=self.context)