Пример #1
0
    def test_list_table(self):
        self.storage_mocker.StubOutWithMock(storage, "list_tables")
        storage.list_tables(IgnoreArg(),
                            exclusive_start_table_name=None,
                            limit=None).AndReturn(['table1', 'table2'])

        self.storage_mocker.ReplayAll()
        self.assertEqual({'TableNames': ['table1', 'table2']},
                         self.DYNAMODB_CON.list_tables())

        self.storage_mocker.VerifyAll()
Пример #2
0
    def test_list_table(self):
        self.storage_mocker.StubOutWithMock(storage, "list_tables")
        storage.list_tables(
            IgnoreArg(), exclusive_start_table_name=None, limit=None
        ).AndReturn(['table1', 'table2'])

        self.storage_mocker.ReplayAll()
        self.assertEqual({'TableNames': ['table1', 'table2']},
                         self.DYNAMODB_CON.list_tables())

        self.storage_mocker.VerifyAll()
Пример #3
0
    def list_tables(self, req, project_id):
        utils.check_project_id(req.context, project_id)
        req.context.tenant = project_id

        params = req.params.copy()

        exclusive_start_table_name = params.pop(
            parser.Props.EXCLUSIVE_START_TABLE_NAME, None)
        if exclusive_start_table_name:
            validation.validate_table_name(exclusive_start_table_name)

        limit = params.pop(parser.Props.LIMIT, None)
        if limit:
            limit = validation.validate_integer(limit,
                                                parser.Props.LIMIT,
                                                min_val=0)

        validation.validate_unexpected_props(params, "params")

        table_names = (storage.list_tables(
            req.context,
            exclusive_start_table_name=exclusive_start_table_name,
            limit=limit))

        res = {}

        if table_names and str(limit) == str(len(table_names)):
            res[parser.Props.LAST_EVALUATED_TABLE_NAME] = table_names[-1]

        res["tables"] = [{"rel": "self", "href": name} for name in table_names]

        return res
Пример #4
0
    def list_tables(self, req, project_id):
        exclusive_start_table_name = (
            req.params.get(parser.Props.EXCLUSIVE_START_TABLE_NAME, None)
        )

        limit = req.params.get(parser.Props.LIMIT, None)

        try:
            table_names = (
                storage.list_tables(
                    req.context,
                    exclusive_start_table_name=exclusive_start_table_name,
                    limit=limit
                )
            )

            res = {}

            if table_names and str(limit) == str(len(table_names)):
                res[parser.Props.LAST_EVALUATED_TABLE_NAME] = table_names[-1]

            res["tables"] = [{"rel": "self", "href": name} for name in
                             table_names]

            return res
        except exception.AWSErrorResponseException as e:
            raise e
        except Exception:
            raise exception.AWSErrorResponseException()
Пример #5
0
    def __call__(self):
        exclusive_start_table_name = (
            self.action_params.get(parser.Props.EXCLUSIVE_START_TABLE_NAME,
                                   None)
        )

        limit = self.action_params.get(parser.Props.LIMIT, None)

        try:
            table_names = (
                storage.list_tables(
                    self.context,
                    exclusive_start_table_name=exclusive_start_table_name,
                    limit=limit)
            )

            res = {parser.Props.TABLE_NAMES: table_names}

            if table_names and limit == len(table_names):
                res[parser.Props.LAST_EVALUATED_TABLE_NAME] = table_names[-1]

            return res
        except exception.AWSErrorResponseException as e:
            raise e
        except Exception:
            raise exception.AWSErrorResponseException()
Пример #6
0
    def list_tables(self, req, project_id):
        LOG.debug(req.path_url)
        req.context.tenant = project_id

        params = req.params.copy()

        exclusive_start_table_name = params.pop(
            parser.Props.EXCLUSIVE_START_TABLE_NAME, None)
        if exclusive_start_table_name:
            validation.validate_table_name(exclusive_start_table_name)

        limit = params.pop(parser.Props.LIMIT, None)
        if limit:
            limit = validation.validate_integer(limit, parser.Props.LIMIT,
                                                min_val=0)

        validation.validate_unexpected_props(params, "params")

        table_names = (
            storage.list_tables(
                req.context,
                exclusive_start_table_name=exclusive_start_table_name,
                limit=limit
            )
        )

        res = {}

        if table_names and str(limit) == str(len(table_names)):
            res[parser.Props.LAST_EVALUATED_TABLE_NAME] = table_names[-1]

        res["tables"] = [{"rel": "self", "href": "{url}/{name}".format(
            url=req.path_url, name=name)} for name in table_names]

        return res
Пример #7
0
    def list_tables(self, req, project_id):
        utils.check_project_id(req.context, project_id)
        req.context.tenant = project_id
        exclusive_start_table_name = req.params.get(
            parser.Props.EXCLUSIVE_START_TABLE_NAME)

        limit = req.params.get(parser.Props.LIMIT)

        table_names = (
            storage.list_tables(
                req.context,
                exclusive_start_table_name=exclusive_start_table_name,
                limit=limit
            )
        )

        res = {}

        if table_names and str(limit) == str(len(table_names)):
            res[parser.Props.LAST_EVALUATED_TABLE_NAME] = table_names[-1]

        res["tables"] = [{"rel": "self", "href": name} for name in
                         table_names]

        return res
Пример #8
0
def list_tables(req, project_id):
    """Returns an array of table describing info associated
    with the current user in given tenant.
    """
    params = req.params.copy()

    exclusive_start_table_name = params.pop(
        parser.Props.EXCLUSIVE_START_TABLE_NAME, None)
    if exclusive_start_table_name:
        validation.validate_table_name(exclusive_start_table_name)

    limit = params.pop(parser.Props.LIMIT, None)
    if limit:
        limit = validation.validate_integer(limit, parser.Props.LIMIT,
                                            min_val=0)

    validation.validate_unexpected_props(params, "params")

    table_names = (
        storage.list_tables(
            project_id,
            exclusive_start_table_name=exclusive_start_table_name,
            limit=limit
        )
    )

    res = {}

    if table_names and str(limit) == str(len(table_names)):
        res[parser.Props.LAST_EVALUATED_TABLE_NAME] = table_names[-1]

    res["tables"] = [{"rel": "self", "href": "{url}/{name}".format(
        url=req.path_url, name=name)} for name in table_names]

    return res
Пример #9
0
    def __call__(self):
        exclusive_start_table_name = (
            self.action_params.get(Props.EXCLUSIVE_START_TABLE_NAME, None)
        )

        limit = self.action_params.get(Props.LIMIT, None)

        table_names = (
            storage.list_tables(
                self.context,
                exclusive_start_table_name=exclusive_start_table_name,
                limit=limit)
        )

        if table_names:
            return {"LastEvaluatedTableName": table_names[-1],
                    "TableNames": table_names}
        else:
            return {}
Пример #10
0
    def list_tables(self, req, project_id):
        utils.check_project_id(req.context, project_id)
        req.context.tenant = project_id
        exclusive_start_table_name = req.params.get(
            parser.Props.EXCLUSIVE_START_TABLE_NAME)

        limit = req.params.get(parser.Props.LIMIT)

        table_names = (storage.list_tables(
            req.context,
            exclusive_start_table_name=exclusive_start_table_name,
            limit=limit))

        res = {}

        if table_names and str(limit) == str(len(table_names)):
            res[parser.Props.LAST_EVALUATED_TABLE_NAME] = table_names[-1]

        res["tables"] = [{"rel": "self", "href": name} for name in table_names]

        return res
Пример #11
0
def project_usage_details(req, project_id):
    """Returns metrics."""
    if 'metrics' not in req.GET:
        keys = ['size', 'item_count']
    else:
        keys = req.GET['metrics'].split(',')

    table_names = storage.list_tables(project_id)

    result = []
    for table_name in table_names:
        try:
            result.append({
                "table_name": table_name,
                "usage_detailes": storage.get_table_statistics(
                    project_id, table_name, keys
                )
            })
        except exception.ValidationError:
            pass

    return result
Пример #12
0
    def project_usage_details(self, req, project_id):
        req.context.tenant = project_id

        if 'metrics' not in req.GET:
            keys = ['size', 'item_count']
        else:
            keys = req.GET['metrics'].split(',')

        table_names = storage.list_tables(req.context)

        result = []
        for table_name in table_names:
            try:
                result.append({
                    "table_name": table_name,
                    "usage_detailes": storage.get_table_statistics(req.context,
                                                                   table_name,
                                                                   keys)
                })
            except exception.ValidationError:
                pass

        return result