func main() {
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tablename1 := "test-godynamo-livetest"
	fmt.Printf("tablename: %s\n", tablename1)

	var code int
	var err error
	var body string

	// CREATE TABLE
	var create1 create.Create
	create1.TableName = tablename1
	create1.ProvisionedThroughput.ReadCapacityUnits = 100
	create1.ProvisionedThroughput.WriteCapacityUnits = 100
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		ep.AttributeDefinition{AttributeName: "TheHashKey", AttributeType: ep.S})
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		ep.AttributeDefinition{AttributeName: "TheRangeKey", AttributeType: ep.N})
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		ep.AttributeDefinition{AttributeName: "AnAttrName", AttributeType: ep.S})
	create1.KeySchema = append(create1.KeySchema,
		ep.KeyDefinition{AttributeName: "TheHashKey", KeyType: ep.HASH})
	create1.KeySchema = append(create1.KeySchema,
		ep.KeyDefinition{AttributeName: "TheRangeKey", KeyType: ep.RANGE})
	lsi := ep.NewLocalSecondaryIndex()
	lsi.IndexName = "AnAttrIndex"
	lsi.Projection.ProjectionType = ep.KEYS_ONLY
	lsi.KeySchema = append(lsi.KeySchema,
		ep.KeyDefinition{AttributeName: "TheHashKey", KeyType: ep.HASH})
	lsi.KeySchema = append(lsi.KeySchema,
		ep.KeyDefinition{AttributeName: "AnAttrName", KeyType: ep.RANGE})
	create1.LocalSecondaryIndexes = append(create1.LocalSecondaryIndexes, *lsi)

	create_json, create_json_err := json.Marshal(create1)
	if create_json_err != nil {
		fmt.Printf("%v\n", create_json_err)
		os.Exit(1)
	}
	fmt.Printf("%s\n", string(create_json))
	fmt.Printf("%v\n", create1)

	cbody, ccode, cerr := create1.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", cbody, ccode, cerr)

	var desc1 desc.Describe
	desc1.TableName = tablename1
	body, code, err = desc1.EndpointReq()
	fmt.Printf("desc:%v\n%v\n,%v\n", body, code, err)

	// WAIT FOR IT TO BE ACTIVE
	fmt.Printf("checking for ACTIVE status for table....\n")
	active, poll_err := desc.PollTableStatus(tablename1, desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	lbody, lcode, lerr := l.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", lbody, lcode, lerr)

}
func main() {
	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// deal with iam, or not
	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tn := "test-godynamo-livetest"
	tablename1 := tn
	fmt.Printf("tablename1: %s\n", tablename1)

	var code int
	var err error
	var body string

	var update_table1 update_table.Request
	update_table1.TableName = tablename1
	update_table1.ProvisionedThroughput.ReadCapacityUnits = 200
	update_table1.ProvisionedThroughput.WriteCapacityUnits = 200
	body, code, err = update_table1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("update table failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}

	// WAIT FOR THE PROVISIONING TO FINISH
	fmt.Printf("checking for ACTIVE status for update....\n")
	active, poll_err := desc.PollTableStatus(tablename1,
		desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	var desc1 desc.Describe
	desc1.TableName = tablename1
	body, code, err = desc1.EndpointReq()
	fmt.Printf("desc:%v\n%v\n,%v\n", body, code, err)

	// WAIT FOR IT TO BE ACTIVE
	fmt.Printf("checking for ACTIVE status for table....\n")
	active, poll_err = desc.PollTableStatus(tablename1, desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	lbody, lcode, lerr := l.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", lbody, lcode, lerr)

}
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	tn := "test-godynamo-livetest"
	tablename1 := tn
	fmt.Printf("tablename1: %s\n", tablename1)

	var code int
	var err error
	var body []byte

	update_table1 := update_table.NewUpdateTable()
	update_table1.TableName = tablename1
	update_table1.ProvisionedThroughput.ReadCapacityUnits = 200
	update_table1.ProvisionedThroughput.WriteCapacityUnits = 200
	body, code, err = update_table1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("update table failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}

	// WAIT FOR THE PROVISIONING TO FINISH
	fmt.Printf("checking for ACTIVE status for update....\n")
	active, poll_err := desc.PollTableStatus(tablename1,
		desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	var desc1 desc.DescribeTable
	desc1.TableName = tablename1
	body, code, err = desc1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("desc failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("desc:%v\n%v\n,%v\n", string(body), code, err)

	// WAIT FOR IT TO BE ACTIVE
	fmt.Printf("checking for ACTIVE status for table....\n")
	active, poll_err = desc.PollTableStatus(tablename1, desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	body, code, err = l.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("list failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

}
// StatusTableHandler is not a standard endpoint. It can be used to poll a table for readiness
// after a CreateTable or UpdateTable request.
func StatusTableHandler(w http.ResponseWriter, req *http.Request) {
	if bbpd_runinfo.BBPDAbortIfClosed(w) {
		return
	}
	start := time.Now()
	if req.Method != "GET" {
		e := "describe_table_route.StatusTableHandler:method only supports GET"
		log.Printf(e)
		http.Error(w, e, http.StatusBadRequest)
		return
	}
	pathElts := strings.Split(req.URL.Path, "/")
	if len(pathElts) != 3 {
		e := "describe_table_route.StatusTableHandler:cannot parse path. try /status-table/TABLENAME"
		log.Printf(e)
		http.Error(w, e, http.StatusBadRequest)
		return
	}
	ue_tn, ue_err := url.QueryUnescape(string(pathElts[2]))
	if ue_err != nil {
		e := fmt.Sprintf("cannot unescape %s, %s",
			string(pathElts[2]), ue_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}

	status := "ACTIVE" // our default key
	if query_status, status_ok := req.URL.Query()["status"]; status_ok {
		status = query_status[0]
	}

	poll := false
	if query_poll, poll_ok := req.URL.Query()["poll"]; poll_ok {
		if query_poll[0] == "1" || query_poll[0] == "yes" {
			poll = true
		}
	}

	tries := 1
	if poll {
		tries = 50
	}
	is_status, status_err := desc.PollTableStatus(
		ue_tn,
		status,
		tries)

	if status_err != nil {
		e := fmt.Sprintf("describe_table_route.StatusTableHandler:cannot get status %s from %s, err %s", status, ue_tn, status_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}

	s := desc.StatusResult{StatusResult: is_status}
	sj, sjerr := json.Marshal(s)
	if sjerr != nil {
		e := fmt.Sprintf("describe_table_route.StatusTableHandler:cannot get convert status to json, err %s", sjerr.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}
	end := time.Now()
	duration := fmt.Sprintf("%v", end.Sub(start))
	w.Header().Set(bbpd_const.CONTENTTYPE, bbpd_const.JSONMIME)
	b, json_err := json.Marshal(bbpd_msg.Response{
		Name:       desc.ENDPOINT_NAME,
		StatusCode: http.StatusOK,
		Body:       sj,
		Run: bbpd_msg.RunInfo{Method: req.Method,
			Host:     bbpd_const.LOCALHOST,
			Duration: duration,
			Start:    start,
			End:      end}})
	if json_err != nil {
		e := fmt.Sprintf("describe_table_route.StatusTableHandler:desc marshal failure %s", json_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}
	io.WriteString(w, string(b))
}
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	tablename1 := "test-godynamo-livetest"
	fmt.Printf("tablename: %s\n", tablename1)

	var code int
	var err error
	var body []byte

	// CREATE TABLE
	create1 := create.NewCreateTable()
	create1.TableName = tablename1
	create1.ProvisionedThroughput.ReadCapacityUnits = 100
	create1.ProvisionedThroughput.WriteCapacityUnits = 100

	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		attributedefinition.AttributeDefinition{AttributeName: "TheHashKey", AttributeType: ep.S})
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		attributedefinition.AttributeDefinition{AttributeName: "TheRangeKey", AttributeType: ep.N})
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		attributedefinition.AttributeDefinition{AttributeName: "AnAttrName", AttributeType: ep.S})
	create1.KeySchema = append(create1.KeySchema,
		keydefinition.KeyDefinition{AttributeName: "TheHashKey", KeyType: ep.HASH})
	create1.KeySchema = append(create1.KeySchema,
		keydefinition.KeyDefinition{AttributeName: "TheRangeKey", KeyType: ep.RANGE})

	lsi := localsecondaryindex.NewLocalSecondaryIndex()
	lsi.IndexName = "AnAttrIndex"
	lsi.Projection.ProjectionType = aws_strings.KEYS_ONLY
	lsi.KeySchema = append(lsi.KeySchema,
		keydefinition.KeyDefinition{AttributeName: "TheHashKey", KeyType: ep.HASH})
	lsi.KeySchema = append(lsi.KeySchema,
		keydefinition.KeyDefinition{AttributeName: "AnAttrName", KeyType: ep.RANGE})
	create1.LocalSecondaryIndexes = append(create1.LocalSecondaryIndexes, *lsi)

	create_json, create_json_err := json.Marshal(create1)
	if create_json_err != nil {
		fmt.Printf("%v\n", create_json_err)
		os.Exit(1)
	}
	fmt.Printf("%s\n", string(create_json))
	fmt.Printf("%v\n", create1)

	body, code, err = create1.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
	if err != nil || code != http.StatusOK {
		fmt.Printf("create failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}

	var desc1 desc.Describe
	desc1.TableName = tablename1
	body, code, err = desc1.EndpointReq()
	fmt.Printf("desc:%v\n%v\n,%v\n", string(body), code, err)
	if err != nil || code != http.StatusOK {
		fmt.Printf("desc failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}

	// WAIT FOR IT TO BE ACTIVE
	fmt.Printf("checking for ACTIVE status for table....\n")
	active, poll_err := desc.PollTableStatus(tablename1, desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	body, code, err = l.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("list failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
}