コード例 #1
0
ファイル: describe_table.py プロジェクト: miarmak/magnetodb
    def __call__(self):

        table_name = self.action_params.get(Props.TABLE_NAME, None)

        if not table_name:
            raise exception.ValidationException(
                message='Table name is not defined')

        try:
            table_meta = storage.describe_table(self.context, table_name)

            result = {
                Props.TABLE: {
                    Props.ATTRIBUTE_DEFINITIONS: (
                        Parser.format_attribute_definitions(
                            table_meta.schema.attribute_type_map
                        )
                    ),
                    Props.CREATION_DATE_TIME: 0,
                    Props.ITEM_COUNT: 0,
                    Props.KEY_SCHEMA: (
                        Parser.format_key_schema(
                            table_meta.schema.key_attributes
                        )
                    ),
                    Props.PROVISIONED_THROUGHPUT: (
                        Values.PROVISIONED_THROUGHPUT_DUMMY
                    ),
                    Props.TABLE_NAME: table_name,
                    Props.TABLE_STATUS: (
                        Parser.format_table_status(table_meta.status)
                    ),
                    Props.TABLE_SIZE_BYTES: 0
                }
            }

            if table_meta.schema.index_def_map:
                table_def = result[Props.TABLE]
                table_def[Props.LOCAL_SECONDARY_INDEXES] = (
                    Parser.format_local_secondary_indexes(
                        table_meta.schema.key_attributes[0],
                        table_meta.schema.index_def_map
                    )
                )
            return result

        except exception.TableNotExistsException as e:
            raise exception.ResourceNotFoundException(e.message)
        except exception.AWSErrorResponseException as e:
            raise e
        except Exception:
            raise exception.AWSErrorResponseException()
コード例 #2
0
ファイル: delete_table.py プロジェクト: miarmak/magnetodb
    def __call__(self):

        table_name = self.action_params.get(Props.TABLE_NAME, None)

        try:
            table_meta = storage.describe_table(self.context, table_name)

            storage.delete_table(self.context, table_name)

            #TODO (isviridov): fill ITEM_COUNT, TABLE_SIZE_BYTES,
            # CREATION_DATE_TIME with real data
            return {
                Props.TABLE_DESCRIPTION: {
                    Props.ATTRIBUTE_DEFINITIONS: (
                        Parser.format_attribute_definitions(
                            table_meta.schema.attribute_type_map
                        )
                    ),
                    Props.CREATION_DATE_TIME: 0,
                    Props.ITEM_COUNT: 0,
                    Props.KEY_SCHEMA: (
                        Parser.format_key_schema(
                            table_meta.schema.key_attributes
                        )
                    ),
                    Props.LOCAL_SECONDARY_INDEXES: (
                        Parser.format_local_secondary_indexes(
                            table_meta.schema.key_attributes[0],
                            table_meta.schema.index_def_map
                        )
                    ),
                    Props.PROVISIONED_THROUGHPUT: (
                        Values.PROVISIONED_THROUGHPUT_DUMMY
                    ),
                    Props.TABLE_NAME: table_name,
                    Props.TABLE_STATUS: Parser.format_table_status(
                        table_meta.status
                    ),
                    Props.TABLE_SIZE_BYTES: 0
                }
            }
        except exception.AWSErrorResponseException as e:
            raise e
        except Exception:
            raise exception.AWSErrorResponseException()
コード例 #3
0
ファイル: describe_table.py プロジェクト: sirmax123/magnetodb
    def __call__(self):

        table_name = self.action_params.get(Props.TABLE_NAME, None)

        table_schema = storage.describe_table(self.context, table_name)

        if not table_name:
#           TODO (isviridov) implement the table not found
#           scenario should be ResourceNotFoundException HTTP status 400
            raise NotImplementedError()
        else:
            return {Props.TABLE: {
                Props.ATTRIBUTE_DEFINITIONS: (
                    map(Parser.format_attribute_definition,
                        table_schema.attribute_defs)
                    ),
                Props.CREATION_DATE_TIME: 0,
                Props.ITEM_COUNT: 0,
                Props.KEY_SCHEMA: (
                    Parser.format_key_schema(
                        table_schema.key_attributes
                    )
                ),
                Props.LOCAL_SECONDARY_INDEXES: (
                    Parser.format_local_secondary_indexes(
                        table_schema.key_attributes[0],
                        table_schema.index_defs
                    )
                ),
                Props.PROVISIONED_THROUGHPUT: (
                    Values.PROVISIONED_THROUGHPUT_DUMMY
                ),
                Props.TABLE_NAME: table_schema.table_name,
                Props.TABLE_STATUS: Values.TABLE_STATUS_ACTIVE,
                Props.TABLE_SIZE_BYTES: 0
            }}