Пример #1
0
// IsTableStatus will test the equality status of a table.
func IsTableStatus(tablename string, status string) (bool, error) {
	d := ep.Endpoint(Describe{TableName: tablename})
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("describe_table.IsTableStatus " +
			"auth must be v4")
		return false, errors.New(e)
	}
	s_resp, s_code, s_err := authreq.RetryReq_V4(d, DESCTABLE_ENDPOINT)
	if s_err != nil {
		e := fmt.Sprintf("describe_table.IsTableStatus: "+
			"check on %s err %s",
			tablename, s_err.Error())
		// if not a 500 problem, don't retry
		if !ep.ServerErr(s_code) {
			return false, errors.New(e)
		}
	}
	if s_resp != "" && s_code == http.StatusOK {
		var resp_json Response
		um_err := json.Unmarshal([]byte(s_resp), &resp_json)
		if um_err != nil {
			um_msg := fmt.Sprintf("describe_table.IsTableStatus:"+
				"cannot unmarshal %s, err: %s\ncheck "+
				"table creation of %s manually",
				s_resp, um_err.Error(), tablename)
			return false, errors.New(um_msg)
		}
		return (resp_json.Table.TableStatus == status), nil
	}
	e := fmt.Sprintf("describe_table.IsTableStatus:does %s exist?", tablename)
	return false, errors.New(e)
}
Пример #2
0
// EndpointReq implements the Endpoint interface.
func (c Create) EndpointReq() (string, int, error) {
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("create_table(Create).EndpointReq " +
			"auth must be v4")
		return "", 0, errors.New(e)
	}
	return authreq.RetryReq_V4(&c, CREATETABLE_ENDPOINT)
}
Пример #3
0
// EndpointReq implements the Endpoint interface.
func (put Put) EndpointReq() (string, int, error) {
	// returns resp_body,code,err
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("put_item(Put).EndpointReq " +
			"auth must be v4")
		return "", 0, errors.New(e)
	}
	return authreq.RetryReq_V4(&put, PUTITEM_ENDPOINT)
}
Пример #4
0
// EndpointReq implements the Endpoint interface.
func (del Delete) EndpointReq() (string,int,error) {
	// returns resp_body,code,err
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("delete_item(Delete).EndpointReq " +
			"auth must be v4")
		return "",0,errors.New(e)
	}
	return authreq.RetryReq_V4(&del,DELETEITEM_ENDPOINT)
}
Пример #5
0
// EndpointReq implements the Endpoint interface.
func (list List) EndpointReq() (string, int, error) {
	// returns resp_body,code,err
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("list_table(List).EndpointReq " +
			"auth must be v4")
		return "", 0, errors.New(e)
	}
	return authreq.RetryReq_V4(&list, LISTTABLE_ENDPOINT)
}
Пример #6
0
// EndpointReq implements the Endpoint interface.
func (s Scan) EndpointReq() (string, int, error) {
	// returns resp_body,code,err
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("scan(Scan).EndpointReq " +
			"auth must be v4")
		return "", 0, errors.New(e)
	}
	return authreq.RetryReq_V4(&s, SCAN_ENDPOINT)
}
Пример #7
0
// EndpointReq implements the Endpoint interface.
func (desc Describe) EndpointReq() (string, int, error) {
	// returns resp_body,code,err
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("describe_table.EndpointReq " +
			"auth must be v4")
		return "", 0, errors.New(e)
	}
	return authreq.RetryReq_V4(&desc, DESCTABLE_ENDPOINT)
}
Пример #8
0
// EndpointReq implements the Endpoint interface.
func (update Update) EndpointReq() (string, int, error) {
	// returns resp_body,code,err
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("update_table(Update).EndpointReq " +
			"auth must be v4")
		return "", 0, errors.New(e)
	}
	return authreq.RetryReq_V4(&update, UPDATETABLE_ENDPOINT)
}
Пример #9
0
// EndpointReq for BatchGetItem which assumes its BatchWriteItem struct instance `b`
// conforms to AWS limits. Use this if you do not employ arbitrarily-sized BatchWriteItems
// and instead choose to conform to the AWS limits.
func (b BatchWriteItem) EndpointReq() (string, int, error) {
	// returns resp_body,code,err
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("batch_write_item(BatchWriteItem).EndpointReq " +
			"auth must be v4")
		return "", 0, errors.New(e)
	}
	return authreq.RetryReq_V4(&b, BATCHWRITE_ENDPOINT)
}
Пример #10
0
// EndpointReq implements the Endpoint interface.
func (q Query) EndpointReq() (string, int, error) {
	// returns resp_body,code,err
	if authreq.AUTH_VERSION != authreq.AUTH_V4 {
		e := fmt.Sprintf("query(Query).EndpointReq " +
			"auth must be v4")
		return "", 0, errors.New(e)
	}
	return authreq.RetryReq_V4(&q, QUERY_ENDPOINT)
}