Esempio n. 1
0
func GetQueue() (Q *sqs.Queue, err os.Error) {
	proxyURL, err := GetProxyURL()
	if err != nil {
		return
	}
	id, err := GetAWSIdentity()
	if err != nil {
		return
	}
	if queueURL != nil && *queueURL != "" {
		qrl, err := http.ParseURL(*queueURL)
		if err == nil {
			ep := awsconn.NewEndpoint(qrl, proxyURL)
			Q = sqs.NewQueueURL(ep)
		}
	} else if queueName != nil && *queueName != "" {
		ep, err := http.ParseURL(*sqsEndpoint)
		if err == nil {
			log.Printf("Parsed EP url: %v", ep)
			ep := awsconn.NewEndpoint(ep, proxyURL)
			_sqs := sqs.NewService(ep)
			Q, err = _sqs.CreateQueue(id, *queueName, 90)
			if err != nil {
				log.Fatalf("Qerr: [%v]", err)
			}
		}
	} else {
		err = os.NewError("Either Queue(+Endpoint) or QueueURL are required")
	}
	return
}
Esempio n. 2
0
// Create a queue, returning the Queue object.
func (self *Service) CreateQueue(id cryptools.NamedSigner, name string, dvtimeout int) (mq *Queue, err os.Error) {
	sqsReq, err := self.signedRequest(id, "/", map[string]string{
		"Action":                   "CreateQueue",
		"QueueName":                name,
		"DefaultVisibilityTimeout": strconv.Itoa(dvtimeout),
	})
	if err != nil {
		return
	}

	xresp := &createQueueResponse{}
	xerr := &errorResponse{}
	err = self.Endpoint.SendParsable(sqsReq, xresp, xerr)

	if err != nil {
		return
	}
	qrl, err := http.ParseURL(xresp.CreateQueueResult.QueueUrl)
	if err != nil {
		return
	}
	ep := awsconn.NewEndpoint(qrl, self.Endpoint.ProxyURL)
	mq = NewQueueURL(ep)
	return
}
Esempio n. 3
0
// List all queues available at an endpoint.
func (self *Service) ListQueues(id cryptools.NamedSigner, prefix string) (out []*Queue, err os.Error) {
	sqsReq, err := self.signedRequest(id, "/", map[string]string{
		"Action": "ListQueues",
	})
	if err != nil {
		return
	}
	xresp := &listQueuesResponse{}
	xerr := &errorResponse{}
	err = self.Endpoint.SendParsable(sqsReq, xresp, xerr)
	if err != nil {
		return
	}
	out = make([]*Queue, len(xresp.ListQueuesResult.QueueUrl))
	for i := range xresp.ListQueuesResult.QueueUrl {
		url, err := http.ParseURL(xresp.ListQueuesResult.QueueUrl[i])
		if err != nil {
			break
		}
		ep := awsconn.NewEndpoint(url, self.Endpoint.ProxyURL)
		out[i] = NewQueueURL(ep)
	}
	//log.Printf("ListQueue: %v",  out)
	return
}
Esempio n. 4
0
func GetEndpoint(region string, proxy *http.URL) (ep *awsconn.Endpoint, err os.Error) {
	url, err := http.ParseURL("http://elasticloadbalancing." + region + ".amazonaws.com")
	if err == nil {
		ep = awsconn.NewEndpoint(url, proxy)
	}
	return
}
Esempio n. 5
0
func GetEndpoint() (ep *awsconn.Endpoint, err os.Error) {
	purl, err := GetProxyURL()
	if err != nil {
		return
	}
	epurl, err := GetEndpointURL()
	if err != nil {
		return
	}
	ep = awsconn.NewEndpoint(epurl, purl)
	return
}
Esempio n. 6
0
func NewPrepaidGateway(signer cryptools.NamedSigner, epurl *http.URL) *PrepaidGateway {
	return &PrepaidGateway{
		signer: signer,
		gwep:   awsconn.NewEndpoint(epurl, nil),
	}
}
Esempio n. 7
0
func main() {
	aws.AwsIDFlags()
	flag.Parse()
	url, err := http.ParseURL(*DBUrl)
	if err != nil {
		log.Fatalf("DBUrl (%s) invalid: (%v)", *DBUrl, err)
	}
	s, err := aws.DefaultIdentity("sha256")
	if err != nil {
		log.Fatalf("Couldn't create identity: %v", err)
	}
	ep := awsconn.NewEndpoint(url, nil)
	dbh := simpledb.NewHandler(simpledb.NewConnection(*ep, "tcp", ""), s)
	if *DoCreate {
		_, err = dbh.CreateDomain(*Domain)
		if err != nil {
			log.Fatalf("Couldn't create domain (req): %v", err)
		}
	}
	if *DoList {
		doms, err := dbh.ListDomains("", 100)
		if err != nil {
			log.Fatalf("Couldn't list domain (req): %v", err)
		}
		for i := range doms {
			fmt.Printf("%s\n", doms[i])
		}
	}
	if *DoPutAttributes {
		attrs, err := FlagAttributes()
		if err != nil {
			log.Fatalf("Error interpreting attr: %v", err)
		}
		err = dbh.PutAttributes(*Domain, *Item, attrs, nil)
	}
	if *DoGetAttributes {
		attrs, err := dbh.GetAttributes(*Domain, *Item, nil, false)
		if err != nil {
			log.Fatalf("Couldn't get item")
		} else {
			for attri := range attrs {
				fmt.Printf("%s\t%s\n", attrs[attri].Name, attrs[attri].Value)
			}
		}
	}
	if *DoDeleteAttributes {
		err = dbh.DeleteAttributes(*Domain, *Item, nil, nil)
		if err != nil {
			log.Fatalf("Couldn't delete item attrs: %v", err)
		}
	}
	if *Select != "" {
		var items []simpledb.Item
		items, err = dbh.Select(*Select, "", false)
		for ii := range items {
			fmt.Printf("%s\n", items[ii].Name)
			for ai := range items[ii].Attribute {
				fmt.Printf("\t%s\t%s\n", items[ii].Attribute[ai].Name,
					items[ii].Attribute[ai].Value)
			}
		}
	}
	if *DoDelete {
		_, err = dbh.DeleteDomain(*Domain)
		if err != nil {
			log.Fatalf("Couldn't delete domain (req): %v", err)
		}
	}
}