Documentation
¶
Overview ¶
Package v1 implements version-1 for DynamoDB-adapter APIs
Index ¶
- func ChangeColumnToSpanner(obj map[string]interface{}) map[string]interface{}
- func ChangeColumnToSpannerExpressionName(tableName string, expressNameMap map[string]string) map[string]string
- func ChangeMaptoDynamoMap(in interface{}) (map[string]interface{}, error)
- func ChangeQueryResponseColumn(tableName string, obj map[string]interface{}) map[string]interface{}
- func ChangeResponseColumn(obj map[string]interface{}) map[string]interface{}
- func ChangeResponseToOriginalColumns(tableName string, obj map[string]interface{}) map[string]interface{}
- func ChangesArrayResponseToOriginalColumns(tableName string, obj []map[string]interface{}) []map[string]interface{}
- func ConvertDynamoArrayToMapArray(tableName string, dynamoMap []map[string]*dynamodb.AttributeValue) ([]map[string]interface{}, error)
- func ConvertDynamoToMap(tableName string, dynamoMap map[string]*dynamodb.AttributeValue) (map[string]interface{}, error)
- func ConvertFromMap(item map[string]*dynamodb.AttributeValue, v interface{}, tableName string) (err error)
- func InitDBAPI(r *gin.Engine)
- func LogRequestResponse() gin.HandlerFunc
- func PanicHandler(c *gin.Context)
- func ReplaceHashRangeExpr(query models.Query) models.Query
- func TransactPut(ctx context.Context, tableName string, putObj map[string]interface{}, ...) (map[string]interface{}, *spanner.Mutation, error)
- func TransactWritePerformOperation(ctx context.Context, action string, actionValue string, ...) (map[string]interface{}, map[string]interface{}, *spanner.Mutation, error)
- func TransactWriteUpdateExpression(ctx context.Context, updateAtrr models.UpdateAttr, ...) (map[string]interface{}, *spanner.Mutation, error)
- func UpdateExpression(ctx context.Context, updateAtrr models.UpdateAttr, svc services.Service) (interface{}, error)
- type APIHandler
- func (h *APIHandler) BatchGetItem(c *gin.Context)
- func (h *APIHandler) BatchWriteItem(c *gin.Context)
- func (h *APIHandler) DeleteItem(c *gin.Context)
- func (h *APIHandler) DescribeTable(c *gin.Context)
- func (h *APIHandler) ExecuteStatement(c *gin.Context)
- func (h *APIHandler) GetItemMeta(c *gin.Context)
- func (h *APIHandler) QueryTable(c *gin.Context)
- func (h *APIHandler) RouteRequest(c *gin.Context)
- func (h *APIHandler) Scan(c *gin.Context)
- func (h *APIHandler) TransactGetItems(c *gin.Context)
- func (h *APIHandler) TransactWriteItems(c *gin.Context)
- func (h *APIHandler) Update(c *gin.Context)
- func (h *APIHandler) UpdateMeta(c *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeColumnToSpanner ¶
ChangeColumnToSpanner converts original column name to spanner supported column names
func ChangeColumnToSpannerExpressionName ¶
func ChangeColumnToSpannerExpressionName(tableName string, expressNameMap map[string]string) map[string]string
ChangeColumnToSpannerExpressionName converts the Column Name into Spanner equivalent
func ChangeMaptoDynamoMap ¶
ChangeMaptoDynamoMap converts simple map into dynamo map
func ChangeQueryResponseColumn ¶
ChangeQueryResponseColumn changes the response into dynamodb response for Query api
func ChangeResponseColumn ¶
ChangeResponseColumn changes the spanner column name into original column if those exists
func ChangeResponseToOriginalColumns ¶
func ChangeResponseToOriginalColumns(tableName string, obj map[string]interface{}) map[string]interface{}
ChangeResponseToOriginalColumns converts the map of spanner column into original column names
func ChangesArrayResponseToOriginalColumns ¶
func ChangesArrayResponseToOriginalColumns(tableName string, obj []map[string]interface{}) []map[string]interface{}
ChangesArrayResponseToOriginalColumns changes the spanner column names to original column names
func ConvertDynamoArrayToMapArray ¶
func ConvertDynamoArrayToMapArray(tableName string, dynamoMap []map[string]*dynamodb.AttributeValue) ([]map[string]interface{}, error)
ConvertDynamoArrayToMapArray this converts Dynamodb Object Array into Map Array
func ConvertDynamoToMap ¶
func ConvertDynamoToMap(tableName string, dynamoMap map[string]*dynamodb.AttributeValue) (map[string]interface{}, error)
ConvertDynamoToMap converts the Dynamodb Object to Map
func ConvertFromMap ¶
func ConvertFromMap(item map[string]*dynamodb.AttributeValue, v interface{}, tableName string) (err error)
ConvertFromMap converts dynamodb AttributeValue into interface
func LogRequestResponse ¶
func LogRequestResponse() gin.HandlerFunc
func PanicHandler ¶
PanicHandler is global handler for all type of panic
func ReplaceHashRangeExpr ¶
ReplaceHashRangeExpr replaces the attribute names from Filter Expression and Range Expression
func TransactPut ¶
func TransactPut(ctx context.Context, tableName string, putObj map[string]interface{}, expr *models.UpdateExpressionCondition, conditionExp string, expressionAttr map[string]interface{}, txn *spanner.ReadWriteTransaction, svc services.Service) (map[string]interface{}, *spanner.Mutation, error)
TransactPut manages a transactional put operation in Spanner, ensuring old data is fetched and conditions are evaluated.
func TransactWritePerformOperation ¶
func TransactWritePerformOperation(ctx context.Context, action string, actionValue string, updateAtrr models.UpdateAttr, oldRes map[string]interface{}, txn *spanner.ReadWriteTransaction, svc services.Service) (map[string]interface{}, map[string]interface{}, *spanner.Mutation, error)
TransactWritePerformOperation performs a transactional write operation based on the given action and actionValue. The operation is performed based on the given action and actionValue. The UpdateAttr struct contains information about the operation, such as the table name, primary key map, condition expression, and expression attribute map. The oldRes map contains the old values of the item, and the txn is the Spanner transaction object.
Args:
ctx: The context.Context object. action: The action to be performed (e.g., DELETE, SET, ADD, REMOVE). actionValue: The value of the action (e.g., "count + 1", "name = :newName"). updateAtrr: The UpdateAttr struct containing information about the operation. oldRes: The old values of the item (map[string]interface{}). txn: The Spanner transaction object.
Returns:
A map of attribute names to their new values (map[string]interface{}), the action value (map[string]interface{}), a Spanner mutation object, and an error.
func TransactWriteUpdateExpression ¶
func TransactWriteUpdateExpression(ctx context.Context, updateAtrr models.UpdateAttr, txn *spanner.ReadWriteTransaction, svc services.Service) (map[string]interface{}, *spanner.Mutation, error)
TransactWriteUpdateExpression is used to update an item in the database with a transaction. If the condition expression fails, the transaction is rolled back.
func UpdateExpression ¶
func UpdateExpression(ctx context.Context, updateAtrr models.UpdateAttr, svc services.Service) (interface{}, error)
UpdateExpression performs an expression
Types ¶
type APIHandler ¶
type APIHandler struct {
// contains filtered or unexported fields
}
func NewAPIHandler ¶
func NewAPIHandler(svc services.Service) *APIHandler
func (*APIHandler) BatchGetItem ¶
func (h *APIHandler) BatchGetItem(c *gin.Context)
BatchGetItem to get with projections @Description Request items in a batch with projections. @Summary Request items in a batch with projections. @ID batch-get-with-projection @Produce json @Success 200 {object} gin.H @Param requestBody body models.BatchGetWithProjectionMeta true "Please add request body of type models.BatchGetWithProjectionMeta" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /batchGetWithProjection/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"
func (*APIHandler) BatchWriteItem ¶
func (h *APIHandler) BatchWriteItem(c *gin.Context)
BatchWriteItem put & delete items in/from table @Description Batch Write Item for putting and deleting data in/from table @Summary Batch Write Items from table @ID batch-write-rows @Produce json @Success 200 {object} gin.H @Param requestBody body models.BatchWriteItem true "Please add request body of type models.BatchWriteItem" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /BatchWriteItem/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"
func (*APIHandler) DeleteItem ¶
func (h *APIHandler) DeleteItem(c *gin.Context)
DeleteItem ... @Description Delete Item from table @Summary Delete Item from table @ID delete-row @Produce json @Success 200 {object} gin.H @Param requestBody body models.Delete true "Please add request body of type models.Delete" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /deleteItem/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"
func (*APIHandler) DescribeTable ¶
func (h *APIHandler) DescribeTable(c *gin.Context)
Test: DescribeTable provides a simple response to indicate the service is operational.
func (*APIHandler) ExecuteStatement ¶
func (h *APIHandler) ExecuteStatement(c *gin.Context)
ExecuteStatement handles the API endpoint for executing PartiQL statements on a specified DynamoDB table. It processes the incoming HTTP request, extracts the JSON body into an ExecuteStatement model, and performs necessary transformations before calling the service to execute the statement.
Parameters: - c: The Gin context, which provides methods for handling HTTP requests and responses.
The function handles: - Tracing using OpenTelemetry for request performance tracking. - JSON binding and validation of the request body into the ExecuteStatement structure. - Extracting the table name from the provided statement and converting parameter values accordingly. - Executing the statement through a service call and managing the response, including changing the response format as needed. - Error handling for various stages of execution.
func (*APIHandler) GetItemMeta ¶
func (h *APIHandler) GetItemMeta(c *gin.Context)
GetItemMeta to get with projections @Description Get a record with projections @Summary Get a record with projections @ID get-with-projection @Produce json @Success 200 {object} gin.H @Param requestBody body models.GetWithProjectionMeta true "Please add request body of type models.GetWithProjectionMeta" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /getWithProjection/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"
func (*APIHandler) QueryTable ¶
func (h *APIHandler) QueryTable(c *gin.Context)
QueryTable queries a table @Description Query a table @Summary Query a table @ID query-table @Produce json @Success 200 {object} gin.H @Param requestBody body models.Query true "Please add request body of type models.Query" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /query/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"
func (*APIHandler) RouteRequest ¶
func (h *APIHandler) RouteRequest(c *gin.Context)
RouteRequest - parse X-Amz-Target and call appropiate handler
func (*APIHandler) Scan ¶
func (h *APIHandler) Scan(c *gin.Context)
Scan record from table @Description Scan records from table @Summary Scan records from table @ID scan @Produce json @Success 200 {object} gin.H @Param requestBody body models.ScanMeta true "Please add request body of type models.ScanMeta" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /scan/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"
func (*APIHandler) TransactGetItems ¶
func (h *APIHandler) TransactGetItems(c *gin.Context)
TransactGetItems to get with projections @Description Request items in a batch with projections. @Summary Request items in a batch with projections. @ID transact-get-with-projection @Produce json @Success 200 {object} gin.H @Param requestBody body models.TransactGetItemsRequest true "Please add request body of type models.TransactGetItemsRequest" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /transactGetItems/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"
func (*APIHandler) TransactWriteItems ¶
func (h *APIHandler) TransactWriteItems(c *gin.Context)
func (*APIHandler) Update ¶
func (h *APIHandler) Update(c *gin.Context)
Update updates a record in Spanner @Description updates a record in Spanner @Summary updates a record in Spanner @ID update @Produce json @Success 200 {object} gin.H @Param requestBody body models.UpdateAttr true "Please add request body of type models.UpdateAttr" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /update/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"
func (*APIHandler) UpdateMeta ¶
func (h *APIHandler) UpdateMeta(c *gin.Context)
UpdateMeta Writes a record @Description Writes a record @Summary Writes record @ID put @Produce json @Success 200 {object} gin.H @Param requestBody body models.Meta true "Please add request body of type models.Meta" @Failure 500 {object} gin.H "{"errorMessage":"We had a problem with our server. Try again later.","errorCode":"E0001"}" @Router /put/ [post] @Failure 401 {object} gin.H "{"errorMessage":"API access not allowed","errorCode": "E0005"}"