diff options
Diffstat (limited to 'vendor/github.com/goamz/goamz/exp')
28 files changed, 0 insertions, 3616 deletions
diff --git a/vendor/github.com/goamz/goamz/exp/mturk/example_test.go b/vendor/github.com/goamz/goamz/exp/mturk/example_test.go deleted file mode 100644 index 806ce95fd..000000000 --- a/vendor/github.com/goamz/goamz/exp/mturk/example_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package mturk_test - -import ( - "fmt" - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/exp/mturk" -) - -var turk *mturk.MTurk - -func ExampleNew() { - // These are your AWS tokens. Note that Turk do not support IAM. - // So you'll have to use your main profile's tokens. - var auth = aws.Auth{AccessKey: "<ACCESS_KEY>", SecretKey: "<SECRET_KEY>"} - turk = mturk.New(auth, true) // true to use sandbox mode -} - -func Examplemturk_CreateHIT_withExternalQuestion() { - question := mturk.ExternalQuestion{ - ExternalURL: "http://www.amazon.com", - FrameHeight: 200, - } - reward := mturk.Price{ - Amount: "0.01", - CurrencyCode: "USD", - } - - hit, err := turk.CreateHIT("title", "description", question, reward, 30, 30, "key1,key2", 3, nil, "annotation") - - if err == nil { - fmt.Println(hit) - } -} - -func Examplemturk_CreateHIT_withHTMLQuestion() { - question := mturk.HTMLQuestion{ - HTMLContent: mturk.HTMLContent{`<![CDATA[ -<!DOCTYPE html> -<html> - <head> - <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/> - <script type='text/javascript' src='https://s3.amazonaws.com/mturk-public/externalHIT_v1.js'></script> - </head> - <body> - <form name='mturk_form' method='post' id='mturk_form' action='https://www.mturk.com/mturk/externalSubmit'> - <input type='hidden' value='' name='assignmentId' id='assignmentId'/> - <h1>What's up?</h1> - <p><textarea name='comment' cols='80' rows='3'></textarea></p> - <p><input type='submit' id='submitButton' value='Submit' /></p></form> - <script language='Javascript'>turkSetAssignmentID();</script> - </body> -</html> -]]>`}, - FrameHeight: 200, - } - reward := mturk.Price{ - Amount: "0.01", - CurrencyCode: "USD", - } - - hit, err := turk.CreateHIT("title", "description", question, reward, 30, 30, "key1,key2", 3, nil, "") - - if err == nil { - fmt.Println(hit) - } -} diff --git a/vendor/github.com/goamz/goamz/exp/mturk/export_test.go b/vendor/github.com/goamz/goamz/exp/mturk/export_test.go deleted file mode 100644 index 736678a56..000000000 --- a/vendor/github.com/goamz/goamz/exp/mturk/export_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package mturk - -import ( - "github.com/goamz/goamz/aws" -) - -func Sign(auth aws.Auth, service, method, timestamp string, params map[string]string) { - sign(auth, service, method, timestamp, params) -} diff --git a/vendor/github.com/goamz/goamz/exp/mturk/mturk.go b/vendor/github.com/goamz/goamz/exp/mturk/mturk.go deleted file mode 100644 index fbbf700c2..000000000 --- a/vendor/github.com/goamz/goamz/exp/mturk/mturk.go +++ /dev/null @@ -1,480 +0,0 @@ -// -// goamz - Go packages to interact with the Amazon Web Services. -// -// https://wiki.ubuntu.com/goamz -// -// Copyright (c) 2011 Canonical Ltd. -// -// Written by Graham Miller <graham.miller@gmail.com> - -// This package is in an experimental state, and does not currently -// follow conventions and style of the rest of goamz or common -// Go conventions. It must be polished before it's considered a -// first-class package in goamz. -package mturk - -import ( - "encoding/xml" - "errors" - "fmt" - "github.com/goamz/goamz/aws" - "net/http" - //"net/http/httputil" - "net/url" - "strconv" - "strings" - "time" -) - -type MTurk struct { - aws.Auth - URL *url.URL -} - -func New(auth aws.Auth, sandbox bool) *MTurk { - mt := &MTurk{Auth: auth} - var err error - if sandbox { - mt.URL, err = url.Parse("https://mechanicalturk.sandbox.amazonaws.com/") - } else { - mt.URL, err = url.Parse("https://mechanicalturk.amazonaws.com/") - } - if err != nil { - panic(err.Error()) - } - return mt -} - -// ---------------------------------------------------------------------------- -// Request dispatching logic. - -// Error encapsulates an error returned by MTurk. -type Error struct { - StatusCode int // HTTP status code (200, 403, ...) - Code string // EC2 error code ("UnsupportedOperation", ...) - Message string // The human-oriented error message - RequestId string -} - -func (err *Error) Error() string { - return err.Message -} - -// The request stanza included in several response types, for example -// in a "CreateHITResponse". http://goo.gl/qGeKf -type xmlRequest struct { - RequestId string - IsValid string - Errors []Error `xml:"Errors>Error"` -} - -/* -A Price represents an amount of money in a given currency. - -Reference: -http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_PriceDataStructureArticle.html -*/ -type Price struct { - // The amount of money, as a number. The amount is in the currency specified - // by the CurrencyCode. For example, if CurrencyCode is USD, the amount will - // be in United States dollars (e.g. 12.75 is $12.75 US). - Amount string - - // A code that represents the country and units of the currency. Its value is - // Type an ISO 4217 currency code, such as USD for United States dollars. - // - // Constraints: Currently only USD is supported. - CurrencyCode string - - // A textual representation of the price, using symbols and formatting - // appropriate for the currency. Symbols are represented using the Unicode - // character set. You do not need to specify FormattedPrice in a request. - // It is only provided by the service in responses, as a convenience to - // your application. - FormattedPrice string -} - -/* -Really just a country string. - -Reference: - -- http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_LocaleDataStructureArticle.html -- http://www.iso.org/iso/country_codes/country_codes -*/ -type Locale string - -/* -A QualificationRequirement describes a Qualification a Worker must -have before the Worker is allowed to accept a HIT. A requirement may optionally -state that a Worker must have the Qualification to preview the HIT. - -Reference: - -http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_QualificationRequirementDataStructureArticle.html -*/ -type QualificationRequirement struct { - // The ID of the Qualification type for the requirement. - // See http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_QualificationRequirementDataStructureArticle.html#ApiReference_QualificationType-IDs - QualificationTypeId string - - // The kind of comparison to make against a Qualification's value. - // Two values can be compared to see if one value is "LessThan", - // "LessThanOrEqualTo", "GreaterThan", "GreaterThanOrEqualTo", "EqualTo", or - // "NotEqualTo" the other. A Qualification requirement can also test if a - // Qualification "Exists" in the user's profile, regardless of its value. - Comparator string - - // The integer value to compare against the Qualification's value. - IntegerValue int - - // The locale value to compare against the Qualification's value, if the - // Qualification being compared is the locale Qualification. - LocaleValue Locale - - // If true, the question data for the HIT will not be shown when a Worker - // whose Qualifications do not meet this requirement tries to preview the HIT. - // That is, a Worker's Qualifications must meet all of the requirements for - // which RequiredToPreview is true in order to preview the HIT. - // - // If a Worker meets all of the requirements where RequiredToPreview is true - // (or if there are no such requirements), but does not meet all of the - // requirements for the HIT, the Worker will be allowed to preview the HIT's - // question data, but will not be allowed to accept and complete the HIT. - RequiredToPreview bool -} - -// Data structure holding the contents of an "external" -// question. http://goo.gl/NP8Aa -type ExternalQuestion struct { - XMLName xml.Name `xml:"http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd ExternalQuestion"` - ExternalURL string - FrameHeight int -} - -// Holds the html content of the HTMLQuestion. -type HTMLContent struct { - Content string `xml:",innerxml"` -} - -// Data structure holding the contents of an "html" -// question. http://goo.gl/hQn5An -type HTMLQuestion struct { - XMLName xml.Name `xml:"http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2011-11-11/HTMLQuestion.xsd HTMLQuestion"` - HTMLContent HTMLContent - - FrameHeight int -} - -// The data structure representing a "human interface task" (HIT) -// Currently only supports "external" questions, because Go -// structs don't support union types. http://goo.gl/NP8Aa -// This type is returned, for example, from SearchHITs -// http://goo.gl/PskcX -type HIT struct { - Request xmlRequest - - HITId string - HITTypeId string - CreationTime string - Title string - Description string - Keywords string - HITStatus string - Reward Price - LifetimeInSeconds uint - AssignmentDurationInSeconds uint - MaxAssignments uint - AutoApprovalDelayInSeconds uint - QualificationRequirement QualificationRequirement - Question interface{} - RequesterAnnotation string - NumberofSimilarHITs uint - HITReviewStatus string - NumberOfAssignmentsPending uint - NumberOfAssignmentsAvailable uint - NumberOfAssignmentsCompleted uint -} - -// The main data structure returned by SearchHITs -// http://goo.gl/PskcX -type SearchHITsResult struct { - NumResults uint - PageNumber uint - TotalNumResults uint - HITs []HIT `xml:"HIT"` -} - -// The wrapper data structure returned by SearchHITs -// http://goo.gl/PskcX -type SearchHITsResponse struct { - RequestId string `xml:"OperationRequest>RequestId"` - SearchHITsResult SearchHITsResult -} - -// The wrapper data structure returned by CreateHIT -// http://goo.gl/PskcX -type CreateHITResponse struct { - RequestId string `xml:"OperationRequest>RequestId"` - HIT HIT -} - -type Assignment struct { - AssignmentId string - WorkerId string - HITId string - AssignmentStatus string - AutoApprovalTime string - AcceptTime string - SubmitTime string - ApprovalTime string - Answer string -} - -func (a Assignment) Answers() (answers map[string]string) { - answers = make(map[string]string) - - decoder := xml.NewDecoder(strings.NewReader(a.Answer)) - - for { - token, _ := decoder.Token() - if token == nil { - break - } - switch startElement := token.(type) { - case xml.StartElement: - if startElement.Name.Local == "Answer" { - var answer struct { - QuestionIdentifier string - FreeText string - } - - decoder.DecodeElement(&answer, &startElement) - answers[answer.QuestionIdentifier] = answer.FreeText - } - } - } - - return -} - -type GetAssignmentsForHITResponse struct { - RequestId string `xml:"OperationRequest>RequestId"` - GetAssignmentsForHITResult struct { - Request xmlRequest - NumResults uint - TotalNumResults uint - PageNumber uint - Assignment Assignment - } -} - -/* -CreateHIT corresponds to the "CreateHIT" operation of the Mechanical Turk -API. Currently only supports "external" questions (see "HIT" struct above). - -Here are the detailed description for the parameters: - - title Required. A title should be short and descriptive about the - kind of task the HIT contains. On the Amazon Mechanical Turk - web site, the HIT title appears in search results, and - everywhere the HIT is mentioned. - description Required. A description includes detailed information about the - kind of task the HIT contains. On the Amazon Mechanical Turk - web site, the HIT description appears in the expanded view of - search results, and in the HIT and assignment screens. A good - description gives the user enough information to evaluate the - HIT before accepting it. - question Required. The data the person completing the HIT uses to produce - the results. Consstraints: Must be a QuestionForm data structure, - an ExternalQuestion data structure, or an HTMLQuestion data - structure. The XML question data must not be larger than 64 - kilobytes (65,535 bytes) in size, including whitespace. - reward Required. The amount of money the Requester will pay a Worker - for successfully completing the HIT. - assignmentDurationInSeconds Required. The amount of time, in seconds, that - a Worker has to complete the HIT after accepting - it. If a Worker does not complete the assignment - within the specified duration, the assignment is - considered abandoned. If the HIT is still - active (that is, its lifetime has not elapsed), - the assignment becomes available for other users - to find and accept. Valid Values: any integer - between 30 (30 seconds) and 31536000 (365 days). - lifetimeInSeconds Required. An amount of time, in seconds, after which the - HIT is no longer available for users to accept. After - the lifetime of the HIT elapses, the HIT no longer - appears in HIT searches, even if not all of the - assignments for the HIT have been accepted. Valid Values: - any integer between 30 (30 seconds) and 31536000 (365 days). - keywords One or more words or phrases that describe the HIT, - separated by commas. These words are used in searches to - find HITs. Constraints: cannot be more than 1,000 - characters. - maxAssignments The number of times the HIT can be accepted and completed - before the HIT becomes unavailable. Valid Values: any - integer between 1 and 1000000000 (1 billion). Default: 1 - qualificationRequirement A condition that a Worker's Qualifications must - meet before the Worker is allowed to accept and - complete the HIT. Constraints: no more than 10 - QualificationRequirement for each HIT. - requesterAnnotation An arbitrary data field. The RequesterAnnotation - parameter lets your application attach arbitrary data to - the HIT for tracking purposes. For example, the - RequesterAnnotation parameter could be an identifier - internal to the Requester's application that corresponds - with the HIT. Constraints: must not be longer than 255 - characters in length. - -Reference: -http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_CreateHITOperation.html -*/ -func (mt *MTurk) CreateHIT( - title, description string, - question interface{}, - reward Price, - assignmentDurationInSeconds, - lifetimeInSeconds uint, - keywords string, - maxAssignments uint, - qualificationRequirement *QualificationRequirement, - requesterAnnotation string) (h *HIT, err error) { - - params := make(map[string]string) - params["Title"] = title - params["Description"] = description - params["Question"], err = xmlEncode(&question) - if err != nil { - return - } - params["Reward.1.Amount"] = reward.Amount - params["Reward.1.CurrencyCode"] = reward.CurrencyCode - params["AssignmentDurationInSeconds"] = strconv.FormatUint(uint64(assignmentDurationInSeconds), 10) - - params["LifetimeInSeconds"] = strconv.FormatUint(uint64(lifetimeInSeconds), 10) - if keywords != "" { - params["Keywords"] = keywords - } - if maxAssignments != 0 { - params["MaxAssignments"] = strconv.FormatUint(uint64(maxAssignments), 10) - } - if qualificationRequirement != nil { - params["QualificationRequirement"], err = xmlEncode(qualificationRequirement) - if err != nil { - return - } - } - if requesterAnnotation != "" { - params["RequesterAnnotation"] = requesterAnnotation - } - - var response CreateHITResponse - err = mt.query(params, "CreateHIT", &response) - if err == nil { - h = &response.HIT - } - return -} - -// Corresponds to the "CreateHIT" operation of the Mechanical Turk -// API, using an existing "hit type". http://goo.gl/cDBRc Currently only -// supports "external" questions (see "HIT" struct above). If -// "maxAssignments" or "requesterAnnotation" are the zero value for -// their types, they will not be included in the request. -func (mt *MTurk) CreateHITOfType(hitTypeId string, q ExternalQuestion, lifetimeInSeconds uint, maxAssignments uint, requesterAnnotation string) (h *HIT, err error) { - params := make(map[string]string) - params["HITTypeId"] = hitTypeId - params["Question"], err = xmlEncode(&q) - if err != nil { - return - } - params["LifetimeInSeconds"] = strconv.FormatUint(uint64(lifetimeInSeconds), 10) - if maxAssignments != 0 { - params["MaxAssignments"] = strconv.FormatUint(uint64(maxAssignments), 10) - } - if requesterAnnotation != "" { - params["RequesterAnnotation"] = requesterAnnotation - } - - var response CreateHITResponse - err = mt.query(params, "CreateHIT", &response) - if err == nil { - h = &response.HIT - } - return -} - -// Get the Assignments for a HIT. -func (mt *MTurk) GetAssignmentsForHIT(hitId string) (r *Assignment, err error) { - params := make(map[string]string) - params["HITId"] = hitId - var response GetAssignmentsForHITResponse - err = mt.query(params, "GetAssignmentsForHIT", &response) - if err == nil { - r = &response.GetAssignmentsForHITResult.Assignment - } - return -} - -// Corresponds to "SearchHITs" operation of Mechanical Turk. http://goo.gl/PskcX -// Currenlty supports none of the optional parameters. -func (mt *MTurk) SearchHITs() (s *SearchHITsResult, err error) { - params := make(map[string]string) - var response SearchHITsResponse - err = mt.query(params, "SearchHITs", &response) - if err == nil { - s = &response.SearchHITsResult - } - return -} - -// Adds common parameters to the "params" map, signs the request, -// adds the signature to the "params" map and sends the request -// to the server. It then unmarshals the response in to the "resp" -// parameter using xml.Unmarshal() -func (mt *MTurk) query(params map[string]string, operation string, resp interface{}) error { - service := "AWSMechanicalTurkRequester" - timestamp := time.Now().UTC().Format("2006-01-02T15:04:05Z") - - params["AWSAccessKeyId"] = mt.Auth.AccessKey - params["Service"] = service - params["Timestamp"] = timestamp - params["Operation"] = operation - - // make a copy - url := *mt.URL - - sign(mt.Auth, service, operation, timestamp, params) - url.RawQuery = multimap(params).Encode() - r, err := http.Get(url.String()) - if err != nil { - return err - } - //dump, _ := httputil.DumpResponse(r, true) - //println("DUMP:\n", string(dump)) - if r.StatusCode != 200 { - return errors.New(fmt.Sprintf("%d: unexpected status code", r.StatusCode)) - } - dec := xml.NewDecoder(r.Body) - err = dec.Decode(resp) - r.Body.Close() - return err -} - -func multimap(p map[string]string) url.Values { - q := make(url.Values, len(p)) - for k, v := range p { - q[k] = []string{v} - } - return q -} - -func xmlEncode(i interface{}) (s string, err error) { - var buf []byte - buf, err = xml.Marshal(i) - if err != nil { - return - } - s = string(buf) - return -} diff --git a/vendor/github.com/goamz/goamz/exp/mturk/mturk_test.go b/vendor/github.com/goamz/goamz/exp/mturk/mturk_test.go deleted file mode 100644 index 0c546571f..000000000 --- a/vendor/github.com/goamz/goamz/exp/mturk/mturk_test.go +++ /dev/null @@ -1,170 +0,0 @@ -package mturk_test - -import ( - "net/url" - "testing" - - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/exp/mturk" - "github.com/goamz/goamz/testutil" - . "gopkg.in/check.v1" -) - -func Test(t *testing.T) { - TestingT(t) -} - -var _ = Suite(&S{}) - -type S struct { - mturk *mturk.MTurk -} - -var testServer = testutil.NewHTTPServer() - -func (s *S) SetUpSuite(c *C) { - testServer.Start() - auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} - u, err := url.Parse(testServer.URL) - if err != nil { - panic(err.Error()) - } - - s.mturk = &mturk.MTurk{ - Auth: auth, - URL: u, - } -} - -func (s *S) TearDownTest(c *C) { - testServer.Flush() -} - -func (s *S) TestCreateHITExternalQuestion(c *C) { - testServer.Response(200, nil, BasicHitResponse) - - question := mturk.ExternalQuestion{ - ExternalURL: "http://www.amazon.com", - FrameHeight: 200, - } - reward := mturk.Price{ - Amount: "0.01", - CurrencyCode: "USD", - } - hit, err := s.mturk.CreateHIT("title", "description", question, reward, 1, 2, "key1,key2", 3, nil, "annotation") - - testServer.WaitRequest() - - c.Assert(err, IsNil) - c.Assert(hit, NotNil) - - c.Assert(hit.HITId, Equals, "28J4IXKO2L927XKJTHO34OCDNASCDW") - c.Assert(hit.HITTypeId, Equals, "2XZ7D1X3V0FKQVW7LU51S7PKKGFKDF") -} - -func (s *S) TestCreateHITHTMLQuestion(c *C) { - testServer.Response(200, nil, BasicHitResponse) - - question := mturk.HTMLQuestion{ - HTMLContent: mturk.HTMLContent{`<![CDATA[ -<!DOCTYPE html> -<html> - <head> - <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/> - <script type='text/javascript' src='https://s3.amazonaws.com/mturk-public/externalHIT_v1.js'></script> - </head> - <body> - <form name='mturk_form' method='post' id='mturk_form' action='https://www.mturk.com/mturk/externalSubmit'> - <input type='hidden' value='' name='assignmentId' id='assignmentId'/> - <h1>What's up?</h1> - <p><textarea name='comment' cols='80' rows='3'></textarea></p> - <p><input type='submit' id='submitButton' value='Submit' /></p></form> - <script language='Javascript'>turkSetAssignmentID();</script> - </body> -</html> -]]>`}, - FrameHeight: 200, - } - reward := mturk.Price{ - Amount: "0.01", - CurrencyCode: "USD", - } - hit, err := s.mturk.CreateHIT("title", "description", question, reward, 1, 2, "key1,key2", 3, nil, "annotation") - - testServer.WaitRequest() - - c.Assert(err, IsNil) - c.Assert(hit, NotNil) - - c.Assert(hit.HITId, Equals, "28J4IXKO2L927XKJTHO34OCDNASCDW") - c.Assert(hit.HITTypeId, Equals, "2XZ7D1X3V0FKQVW7LU51S7PKKGFKDF") -} - -func (s *S) TestSearchHITs(c *C) { - testServer.Response(200, nil, SearchHITResponse) - - hitResult, err := s.mturk.SearchHITs() - - c.Assert(err, IsNil) - c.Assert(hitResult, NotNil) - - c.Assert(hitResult.NumResults, Equals, uint(1)) - c.Assert(hitResult.PageNumber, Equals, uint(1)) - c.Assert(hitResult.TotalNumResults, Equals, uint(1)) - - c.Assert(len(hitResult.HITs), Equals, 1) - c.Assert(hitResult.HITs[0].HITId, Equals, "2BU26DG67D1XTE823B3OQ2JF2XWF83") - c.Assert(hitResult.HITs[0].HITTypeId, Equals, "22OWJ5OPB0YV6IGL5727KP9U38P5XR") - c.Assert(hitResult.HITs[0].CreationTime, Equals, "2011-12-28T19:56:20Z") - c.Assert(hitResult.HITs[0].Title, Equals, "test hit") - c.Assert(hitResult.HITs[0].Description, Equals, "please disregard, testing only") - c.Assert(hitResult.HITs[0].HITStatus, Equals, "Reviewable") - c.Assert(hitResult.HITs[0].MaxAssignments, Equals, uint(1)) - c.Assert(hitResult.HITs[0].Reward.Amount, Equals, "0.01") - c.Assert(hitResult.HITs[0].Reward.CurrencyCode, Equals, "USD") - c.Assert(hitResult.HITs[0].AutoApprovalDelayInSeconds, Equals, uint(2592000)) - c.Assert(hitResult.HITs[0].AssignmentDurationInSeconds, Equals, uint(30)) - c.Assert(hitResult.HITs[0].NumberOfAssignmentsPending, Equals, uint(0)) - c.Assert(hitResult.HITs[0].NumberOfAssignmentsAvailable, Equals, uint(1)) - c.Assert(hitResult.HITs[0].NumberOfAssignmentsCompleted, Equals, uint(0)) -} - -func (s *S) TestGetAssignmentsForHIT_NoAnswer(c *C) { - testServer.Response(200, nil, GetAssignmentsForHITNoAnswerResponse) - - assignment, err := s.mturk.GetAssignmentsForHIT("emptyassignment") - - testServer.WaitRequest() - - c.Assert(err, IsNil) - c.Assert(assignment, NotNil) - - c.Assert(assignment.HITId, Equals, "") -} - -func (s *S) TestGetAssignmentsForHIT_Answer(c *C) { - testServer.Response(200, nil, GetAssignmentsForHITAnswerResponse) - - assignment, err := s.mturk.GetAssignmentsForHIT("emptyassignment") - - testServer.WaitRequest() - - c.Assert(err, IsNil) - c.Assert(assignment, NotNil) - - c.Assert(assignment.AssignmentId, Equals, "2QKNTL0XULRGFAQWUWDD05FP94V2O3") - c.Assert(assignment.WorkerId, Equals, "A1ZUQ2YDM61713") - c.Assert(assignment.HITId, Equals, "2W36VCPWZ9RN5DX1MBJ7VN3D6WEPAM") - c.Assert(assignment.AssignmentStatus, Equals, "Submitted") - c.Assert(assignment.AutoApprovalTime, Equals, "2014-02-26T09:39:48Z") - c.Assert(assignment.AcceptTime, Equals, "2014-01-27T09:39:38Z") - c.Assert(assignment.SubmitTime, Equals, "2014-01-27T09:39:48Z") - c.Assert(assignment.ApprovalTime, Equals, "") - - answers := assignment.Answers() - c.Assert(len(answers), Equals, 4) - c.Assert(answers["tags"], Equals, "asd") - c.Assert(answers["text_in_image"], Equals, "asd") - c.Assert(answers["is_pattern"], Equals, "yes") - c.Assert(answers["is_map"], Equals, "yes") -} diff --git a/vendor/github.com/goamz/goamz/exp/mturk/responses_test.go b/vendor/github.com/goamz/goamz/exp/mturk/responses_test.go deleted file mode 100644 index abc483945..000000000 --- a/vendor/github.com/goamz/goamz/exp/mturk/responses_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package mturk_test - -var BasicHitResponse = `<?xml version="1.0"?> -<CreateHITResponse><OperationRequest><RequestId>643b794b-66b6-4427-bb8a-4d3df5c9a20e</RequestId></OperationRequest><HIT><Request><IsValid>True</IsValid></Request><HITId>28J4IXKO2L927XKJTHO34OCDNASCDW</HITId><HITTypeId>2XZ7D1X3V0FKQVW7LU51S7PKKGFKDF</HITTypeId></HIT></CreateHITResponse> -` - -var SearchHITResponse = `<?xml version="1.0"?> -<SearchHITsResponse><OperationRequest><RequestId>38862d9c-f015-4177-a2d3-924110a9d6f2</RequestId></OperationRequest><SearchHITsResult><Request><IsValid>True</IsValid></Request><NumResults>1</NumResults><TotalNumResults>1</TotalNumResults><PageNumber>1</PageNumber><HIT><HITId>2BU26DG67D1XTE823B3OQ2JF2XWF83</HITId><HITTypeId>22OWJ5OPB0YV6IGL5727KP9U38P5XR</HITTypeId><CreationTime>2011-12-28T19:56:20Z</CreationTime><Title>test hit</Title><Description>please disregard, testing only</Description><HITStatus>Reviewable</HITStatus><MaxAssignments>1</MaxAssignments><Reward><Amount>0.01</Amount><CurrencyCode>USD</CurrencyCode><FormattedPrice>$0.01</FormattedPrice></Reward><AutoApprovalDelayInSeconds>2592000</AutoApprovalDelayInSeconds><Expiration>2011-12-28T19:56:50Z</Expiration><AssignmentDurationInSeconds>30</AssignmentDurationInSeconds><NumberOfAssignmentsPending>0</NumberOfAssignmentsPending><NumberOfAssignmentsAvailable>1</NumberOfAssignmentsAvailable><NumberOfAssignmentsCompleted>0</NumberOfAssignmentsCompleted></HIT></SearchHITsResult></SearchHITsResponse> -` - -var GetAssignmentsForHITNoAnswerResponse = `<?xml version="1.0"?> -<GetAssignmentsForHITResponse><OperationRequest><RequestId>536934be-a35b-4e4e-9822-72fbf36d5862</RequestId></OperationRequest><GetAssignmentsForHITResult><Request><IsValid>True</IsValid></Request><NumResults>0</NumResults><TotalNumResults>0</TotalNumResults><PageNumber>1</PageNumber></GetAssignmentsForHITResult></GetAssignmentsForHITResponse> -` - -var GetAssignmentsForHITAnswerResponse = `<?xml version="1.0"?> -<GetAssignmentsForHITResponse><OperationRequest><RequestId>2f113bdf-2e3e-4c5a-a396-3ed01384ecb9</RequestId></OperationRequest><GetAssignmentsForHITResult><Request><IsValid>True</IsValid></Request><NumResults>1</NumResults><TotalNumResults>1</TotalNumResults><PageNumber>1</PageNumber><Assignment><AssignmentId>2QKNTL0XULRGFAQWUWDD05FP94V2O3</AssignmentId><WorkerId>A1ZUQ2YDM61713</WorkerId><HITId>2W36VCPWZ9RN5DX1MBJ7VN3D6WEPAM</HITId><AssignmentStatus>Submitted</AssignmentStatus><AutoApprovalTime>2014-02-26T09:39:48Z</AutoApprovalTime><AcceptTime>2014-01-27T09:39:38Z</AcceptTime><SubmitTime>2014-01-27T09:39:48Z</SubmitTime><Answer><?xml version="1.0" encoding="UTF-8" standalone="no"?> -<QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd"> -<Answer> -<QuestionIdentifier>tags</QuestionIdentifier> -<FreeText>asd</FreeText> -</Answer> -<Answer> -<QuestionIdentifier>text_in_image</QuestionIdentifier> -<FreeText>asd</FreeText> -</Answer> -<Answer> -<QuestionIdentifier>is_pattern</QuestionIdentifier> -<FreeText>yes</FreeText> -</Answer> -<Answer> -<QuestionIdentifier>is_map</QuestionIdentifier> -<FreeText>yes</FreeText> -</Answer> -</QuestionFormAnswers> -</Answer></Assignment></GetAssignmentsForHITResult></GetAssignmentsForHITResponse> -` diff --git a/vendor/github.com/goamz/goamz/exp/mturk/sign.go b/vendor/github.com/goamz/goamz/exp/mturk/sign.go deleted file mode 100644 index f2ff8cbfe..000000000 --- a/vendor/github.com/goamz/goamz/exp/mturk/sign.go +++ /dev/null @@ -1,22 +0,0 @@ -package mturk - -import ( - "crypto/hmac" - "crypto/sha1" - "encoding/base64" - "github.com/goamz/goamz/aws" -) - -var b64 = base64.StdEncoding - -// ---------------------------------------------------------------------------- -// Mechanical Turk signing (http://goo.gl/wrzfn) -func sign(auth aws.Auth, service, method, timestamp string, params map[string]string) { - payload := service + method + timestamp - hash := hmac.New(sha1.New, []byte(auth.SecretKey)) - hash.Write([]byte(payload)) - signature := make([]byte, b64.EncodedLen(hash.Size())) - b64.Encode(signature, hash.Sum(nil)) - - params["Signature"] = string(signature) -} diff --git a/vendor/github.com/goamz/goamz/exp/mturk/sign_test.go b/vendor/github.com/goamz/goamz/exp/mturk/sign_test.go deleted file mode 100644 index 49296eb73..000000000 --- a/vendor/github.com/goamz/goamz/exp/mturk/sign_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package mturk_test - -import ( - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/exp/mturk" - . "gopkg.in/check.v1" -) - -// Mechanical Turk REST authentication docs: http://goo.gl/wrzfn - -var testAuth = aws.Auth{AccessKey: "user", SecretKey: "secret"} - -// == fIJy9wCApBNL2R4J2WjJGtIBFX4= -func (s *S) TestBasicSignature(c *C) { - params := map[string]string{} - mturk.Sign(testAuth, "AWSMechanicalTurkRequester", "CreateHIT", "2012-02-16T20:30:47Z", params) - expected := "b/TnvzrdeD/L/EyzdFrznPXhido=" - c.Assert(params["Signature"], Equals, expected) -} diff --git a/vendor/github.com/goamz/goamz/exp/sdb/export_test.go b/vendor/github.com/goamz/goamz/exp/sdb/export_test.go deleted file mode 100644 index 7807a914a..000000000 --- a/vendor/github.com/goamz/goamz/exp/sdb/export_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package sdb - -import ( - "github.com/goamz/goamz/aws" -) - -func Sign(auth aws.Auth, method, path string, params map[string][]string, headers map[string][]string) { - sign(auth, method, path, params, headers) -} diff --git a/vendor/github.com/goamz/goamz/exp/sdb/responses_test.go b/vendor/github.com/goamz/goamz/exp/sdb/responses_test.go deleted file mode 100644 index 034c2b31c..000000000 --- a/vendor/github.com/goamz/goamz/exp/sdb/responses_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package sdb_test - -var TestCreateDomainXmlOK = ` -<?xml version="1.0"?> -<CreateDomainResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> - <ResponseMetadata> - <RequestId>63264005-7a5f-e01a-a224-395c63b89f6d</RequestId> - <BoxUsage>0.0055590279</BoxUsage> - </ResponseMetadata> -</CreateDomainResponse> -` - -var TestListDomainsXmlOK = ` -<?xml version="1.0"?> -<ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> - <ListDomainsResult> - <DomainName>Account</DomainName> - <DomainName>Domain</DomainName> - <DomainName>Record</DomainName> - </ListDomainsResult> - <ResponseMetadata> - <RequestId>15fcaf55-9914-63c2-21f3-951e31193790</RequestId> - <BoxUsage>0.0000071759</BoxUsage> - </ResponseMetadata> -</ListDomainsResponse> -` - -var TestListDomainsWithNextTokenXmlOK = ` -<?xml version="1.0"?> -<ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> - <ListDomainsResult> - <DomainName>Domain1-200706011651</DomainName> - <DomainName>Domain2-200706011652</DomainName> - <NextToken>TWV0ZXJpbmdUZXN0RG9tYWluMS0yMDA3MDYwMTE2NTY=</NextToken> - </ListDomainsResult> - <ResponseMetadata> - <RequestId>eb13162f-1b95-4511-8b12-489b86acfd28</RequestId> - <BoxUsage>0.0000219907</BoxUsage> - </ResponseMetadata> -</ListDomainsResponse> -` - -var TestDeleteDomainXmlOK = ` -<?xml version="1.0"?> -<DeleteDomainResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> - <ResponseMetadata> - <RequestId>039e1e25-9a64-2a74-93da-2fda36122a97</RequestId> - <BoxUsage>0.0055590278</BoxUsage> - </ResponseMetadata> -</DeleteDomainResponse> -` - -var TestDomainMetadataXmlNoSuchDomain = ` -<?xml version="1.0"?> -<Response xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> - <Errors> - <Error> - <Code>NoSuchDomain</Code> - <Message>The specified domain does not exist.</Message> - <BoxUsage>0.0000071759</BoxUsage> - </Error> - </Errors> - <RequestID>e050cea2-a772-f90e-2cb0-98ebd42c2898</RequestID> -</Response> -` - -var TestPutAttrsXmlOK = ` -<?xml version="1.0"?> -<PutAttributesResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> - <ResponseMetadata> - <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> - <BoxUsage>0.0000219907</BoxUsage> - </ResponseMetadata> -</PutAttributesResponse> -` - -var TestAttrsXmlOK = ` -<?xml version="1.0"?> -<GetAttributesResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> - <GetAttributesResult> - <Attribute><Name>Color</Name><Value>Blue</Value></Attribute> - <Attribute><Name>Size</Name><Value>Med</Value></Attribute> - </GetAttributesResult> - <ResponseMetadata> - <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId> - <BoxUsage>0.0000219942</BoxUsage> - </ResponseMetadata> -</GetAttributesResponse> -` - -var TestSelectXmlOK = ` -<?xml version="1.0"?> -<SelectResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> - <SelectResult> - <Item> - <Name>Item_03</Name> - <Attribute><Name>Category</Name><Value>Clothes</Value></Attribute> - <Attribute><Name>Subcategory</Name><Value>Pants</Value></Attribute> - <Attribute><Name>Name</Name><Value>Sweatpants</Value></Attribute> - <Attribute><Name>Color</Name><Value>Blue</Value></Attribute> - <Attribute><Name>Color</Name><Value>Yellow</Value></Attribute> - <Attribute><Name>Color</Name><Value>Pink</Value></Attribute> - <Attribute><Name>Size</Name><Value>Large</Value></Attribute> - </Item> - <Item> - <Name>Item_06</Name> - <Attribute><Name>Category</Name><Value>Motorcycle Parts</Value></Attribute> - <Attribute><Name>Subcategory</Name><Value>Bodywork</Value></Attribute> - <Attribute><Name>Name</Name><Value>Fender Eliminator</Value></Attribute> - <Attribute><Name>Color</Name><Value>Blue</Value></Attribute> - <Attribute><Name>Make</Name><Value>Yamaha</Value></Attribute> - <Attribute><Name>Model</Name><Value>R1</Value></Attribute> - </Item> - </SelectResult> - <ResponseMetadata> - <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId> - <BoxUsage>0.0000219907</BoxUsage> - </ResponseMetadata> -</SelectResponse> -` diff --git a/vendor/github.com/goamz/goamz/exp/sdb/sdb.go b/vendor/github.com/goamz/goamz/exp/sdb/sdb.go deleted file mode 100644 index 0d13f4a9e..000000000 --- a/vendor/github.com/goamz/goamz/exp/sdb/sdb.go +++ /dev/null @@ -1,413 +0,0 @@ -// -// goamz - Go packages to interact with the Amazon Web Services. -// -// https://wiki.ubuntu.com/goamz -// -// Copyright (c) 2011 AppsAttic Ltd. -// -// sdb package written by: -// -// Andrew Chilton <chilts@appsattic.com> -// Brad Rydzewski <brad.rydzewski@gmail.com> - -// This package is in an experimental state, and does not currently -// follow conventions and style of the rest of goamz or common -// Go conventions. It must be polished before it's considered a -// first-class package in goamz. -package sdb - -// BUG: SelectResp isn't properly organized. It must change. - -// - -import ( - "encoding/xml" - "github.com/goamz/goamz/aws" - "log" - "net/http" - "net/http/httputil" - "net/url" - "strconv" - "time" -) - -const debug = false - -// The SDB type encapsulates operations with a specific SimpleDB region. -type SDB struct { - aws.Auth - aws.Region - private byte // Reserve the right of using private data. -} - -// New creates a new SDB. -func New(auth aws.Auth, region aws.Region) *SDB { - return &SDB{auth, region, 0} -} - -// The Domain type represents a collection of items that are described -// by name-value attributes. -type Domain struct { - *SDB - Name string -} - -// Domain returns a Domain with the given name. -func (sdb *SDB) Domain(name string) *Domain { - return &Domain{sdb, name} -} - -// The Item type represent individual objects that contain one or more -// name-value attributes stored within a SDB Domain as rows. -type Item struct { - *SDB - *Domain - Name string -} - -// Item returns an Item with the given name. -func (domain *Domain) Item(name string) *Item { - return &Item{domain.SDB, domain, name} -} - -// The Attr type represent categories of data that can be assigned to items. -type Attr struct { - Name string - Value string -} - -// ---------------------------------------------------------------------------- -// Service-level operations. - -// --- ListDomains - -// Response to a ListDomains request. -// -// See http://goo.gl/3u0Cf for more details. -type ListDomainsResp struct { - Domains []string `xml:"ListDomainsResult>DomainName"` - NextToken string `xml:"ListDomainsResult>NextToken"` - ResponseMetadata ResponseMetadata -} - -// ListDomains lists all domains in sdb. -// -// See http://goo.gl/Dsw15 for more details. -func (sdb *SDB) ListDomains() (resp *ListDomainsResp, err error) { - return sdb.ListDomainsN(0, "") -} - -// ListDomainsN lists domains in sdb up to maxDomains. -// If nextToken is not empty, domains listed will start at the given token. -// -// See http://goo.gl/Dsw15 for more details. -func (sdb *SDB) ListDomainsN(maxDomains int, nextToken string) (resp *ListDomainsResp, err error) { - params := makeParams("ListDomains") - if maxDomains != 0 { - params["MaxNumberOfDomains"] = []string{strconv.Itoa(maxDomains)} - } - if nextToken != "" { - params["NextToken"] = []string{nextToken} - } - resp = &ListDomainsResp{} - err = sdb.query(nil, nil, params, nil, resp) - return -} - -// --- SelectExpression - -// Response to a Select request. -// -// See http://goo.gl/GTsSZ for more details. -type SelectResp struct { - Items []struct { - Name string - Attrs []Attr `xml:"Attribute"` - } `xml:"SelectResult>Item"` - ResponseMetadata ResponseMetadata -} - -// Select returns a set of items and attributes that match expr. -// Select is similar to the standard SQL SELECT statement. -// -// See http://goo.gl/GTsSZ for more details. -func (sdb *SDB) Select(expr string, consistent bool) (resp *SelectResp, err error) { - resp = &SelectResp{} - params := makeParams("Select") - params["SelectExpression"] = []string{expr} - if consistent { - params["ConsistentRead"] = []string{"true"} - } - err = sdb.query(nil, nil, params, nil, resp) - return -} - -// ---------------------------------------------------------------------------- -// Domain-level operations. - -// --- CreateDomain - -// CreateDomain creates a new domain. -// -// See http://goo.gl/jDjGH for more details. -func (domain *Domain) CreateDomain() (resp *SimpleResp, err error) { - params := makeParams("CreateDomain") - resp = &SimpleResp{} - err = domain.SDB.query(domain, nil, params, nil, resp) - return -} - -// DeleteDomain deletes an existing domain. -// -// See http://goo.gl/S0dCL for more details. -func (domain *Domain) DeleteDomain() (resp *SimpleResp, err error) { - params := makeParams("DeleteDomain") - resp = &SimpleResp{} - err = domain.SDB.query(domain, nil, params, nil, resp) - return -} - -// ---------------------------------------------------------------------------- -// Item-level operations. - -type PutAttrs struct { - attrs []Attr - expected []Attr - replace map[string]bool - missing map[string]bool -} - -func (pa *PutAttrs) Add(name, value string) { - pa.attrs = append(pa.attrs, Attr{name, value}) -} - -func (pa *PutAttrs) Replace(name, value string) { - pa.Add(name, value) - if pa.replace == nil { - pa.replace = make(map[string]bool) - } - pa.replace[name] = true -} - -// The PutAttrs request will only succeed if the existing -// item in SimpleDB contains a matching name / value pair. -func (pa *PutAttrs) IfValue(name, value string) { - pa.expected = append(pa.expected, Attr{name, value}) -} - -// Flag to test the existence of an attribute while performing -// conditional updates. X can be any positive integer or 0. -// -// This should set Expected.N.Name=name and Expected.N.Exists=false -func (pa *PutAttrs) IfMissing(name string) { - if pa.missing == nil { - pa.missing = make(map[string]bool) - } - pa.missing[name] = true -} - -// PutAttrs adds attrs to item. -// -// See http://goo.gl/yTAV4 for more details. -func (item *Item) PutAttrs(attrs *PutAttrs) (resp *SimpleResp, err error) { - params := makeParams("PutAttributes") - resp = &SimpleResp{} - - // copy these attrs over to the parameters - itemNum := 1 - for _, attr := range attrs.attrs { - itemNumStr := strconv.Itoa(itemNum) - - // do the name, value and replace - params["Attribute."+itemNumStr+".Name"] = []string{attr.Name} - params["Attribute."+itemNumStr+".Value"] = []string{attr.Value} - - if _, ok := attrs.replace[attr.Name]; ok { - params["Attribute."+itemNumStr+".Replace"] = []string{"true"} - } - - itemNum++ - } - - //append expected values to params - expectedNum := 1 - for _, attr := range attrs.expected { - expectedNumStr := strconv.Itoa(expectedNum) - params["Expected."+expectedNumStr+".Name"] = []string{attr.Name} - params["Expected."+expectedNumStr+".Value"] = []string{attr.Value} - - if attrs.missing[attr.Name] { - params["Expected."+expectedNumStr+".Exists"] = []string{"false"} - } - expectedNum++ - } - - err = item.query(params, nil, resp) - if err != nil { - return nil, err - } - return -} - -// Response to an Attrs request. -// -// See http://goo.gl/45X1M for more details. -type AttrsResp struct { - Attrs []Attr `xml:"GetAttributesResult>Attribute"` - ResponseMetadata ResponseMetadata -} - -// Attrs returns one or more of the named attributes, or -// all of item's attributes if names is nil. -// If consistent is true, previous writes will necessarily -// be observed. -// -// See http://goo.gl/45X1M for more details. -func (item *Item) Attrs(names []string, consistent bool) (resp *AttrsResp, err error) { - params := makeParams("GetAttributes") - params["ItemName"] = []string{item.Name} - if consistent { - params["ConsistentRead"] = []string{"true"} - } - - // Copy these attributes over to the parameters - for i, name := range names { - params["AttributeName."+strconv.Itoa(i+1)] = []string{name} - } - - resp = &AttrsResp{} - err = item.query(params, nil, resp) - if err != nil { - return nil, err - } - return -} - -// ---------------------------------------------------------------------------- -// Generic data structures for all requests/responses. - -// Error encapsulates an error returned by SDB. -type Error struct { - StatusCode int // HTTP status code (200, 403, ...) - StatusMsg string // HTTP status message ("Service Unavailable", "Bad Request", ...) - Code string // SimpleDB error code ("InvalidParameterValue", ...) - Message string // The human-oriented error message - RequestId string // A unique ID for this request - BoxUsage float64 // The measure of machine utilization for this request. -} - -func (err *Error) Error() string { - return err.Message -} - -// SimpleResp represents a response to an SDB request which on success -// will return no other information besides ResponseMetadata. -type SimpleResp struct { - ResponseMetadata ResponseMetadata -} - -// ResponseMetadata -type ResponseMetadata struct { - RequestId string // A unique ID for tracking the request - BoxUsage float64 // The measure of machine utilization for this request. -} - -func buildError(r *http.Response) error { - err := Error{} - err.StatusCode = r.StatusCode - err.StatusMsg = r.Status - xml.NewDecoder(r.Body).Decode(&err) - return &err -} - -// ---------------------------------------------------------------------------- -// Request dispatching logic. - -func (item *Item) query(params url.Values, headers http.Header, resp interface{}) error { - return item.Domain.SDB.query(item.Domain, item, params, headers, resp) -} - -func (domain *Domain) query(item *Item, params url.Values, headers http.Header, resp interface{}) error { - return domain.SDB.query(domain, item, params, headers, resp) -} - -func (sdb *SDB) query(domain *Domain, item *Item, params url.Values, headers http.Header, resp interface{}) error { - // all SimpleDB operations have path="/" - method := "GET" - path := "/" - - // if we have been given no headers or params, create them - if headers == nil { - headers = map[string][]string{} - } - if params == nil { - params = map[string][]string{} - } - - // setup some default parameters - params["Version"] = []string{"2009-04-15"} - params["Timestamp"] = []string{time.Now().UTC().Format(time.RFC3339)} - - // set the DomainName param (every request must have one) - if domain != nil { - params["DomainName"] = []string{domain.Name} - } - - // set the ItemName if we have one - if item != nil { - params["ItemName"] = []string{item.Name} - } - - // check the endpoint URL - u, err := url.Parse(sdb.Region.SDBEndpoint) - if err != nil { - return err - } - headers["Host"] = []string{u.Host} - sign(sdb.Auth, method, path, params, headers) - - u.Path = path - if len(params) > 0 { - u.RawQuery = params.Encode() - } - req := http.Request{ - URL: u, - Method: method, - ProtoMajor: 1, - ProtoMinor: 1, - Close: true, - Header: headers, - } - - if v, ok := headers["Content-Length"]; ok { - req.ContentLength, _ = strconv.ParseInt(v[0], 10, 64) - delete(headers, "Content-Length") - } - - r, err := http.DefaultClient.Do(&req) - if err != nil { - return err - } - defer r.Body.Close() - - if debug { - dump, _ := httputil.DumpResponse(r, true) - log.Printf("response:\n") - log.Printf("%v\n}\n", string(dump)) - } - - // status code is always 200 when successful (since we're always doing a GET) - if r.StatusCode != 200 { - return buildError(r) - } - - // everything was fine, so unmarshal the XML and return what it's err is (if any) - err = xml.NewDecoder(r.Body).Decode(resp) - return err -} - -func makeParams(action string) map[string][]string { - params := make(map[string][]string) - params["Action"] = []string{action} - return params -} diff --git a/vendor/github.com/goamz/goamz/exp/sdb/sdb_test.go b/vendor/github.com/goamz/goamz/exp/sdb/sdb_test.go deleted file mode 100644 index 83e7f9f86..000000000 --- a/vendor/github.com/goamz/goamz/exp/sdb/sdb_test.go +++ /dev/null @@ -1,219 +0,0 @@ -package sdb_test - -import ( - "testing" - - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/exp/sdb" - "github.com/goamz/goamz/testutil" - . "gopkg.in/check.v1" -) - -func Test(t *testing.T) { - TestingT(t) -} - -var _ = Suite(&S{}) - -type S struct { - sdb *sdb.SDB -} - -var testServer = testutil.NewHTTPServer() - -func (s *S) SetUpSuite(c *C) { - testServer.Start() - auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} - s.sdb = sdb.New(auth, aws.Region{SDBEndpoint: testServer.URL}) -} - -func (s *S) TearDownTest(c *C) { - testServer.Flush() -} - -func (s *S) TestCreateDomainOK(c *C) { - testServer.Response(200, nil, TestCreateDomainXmlOK) - - domain := s.sdb.Domain("domain") - resp, err := domain.CreateDomain() - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.ResponseMetadata.RequestId, Equals, "63264005-7a5f-e01a-a224-395c63b89f6d") - c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0055590279) - - c.Assert(err, IsNil) -} - -func (s *S) TestListDomainsOK(c *C) { - testServer.Response(200, nil, TestListDomainsXmlOK) - - resp, err := s.sdb.ListDomains() - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.ResponseMetadata.RequestId, Equals, "15fcaf55-9914-63c2-21f3-951e31193790") - c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000071759) - c.Assert(resp.Domains, DeepEquals, []string{"Account", "Domain", "Record"}) - - c.Assert(err, IsNil) -} - -func (s *S) TestListDomainsWithNextTokenXmlOK(c *C) { - testServer.Response(200, nil, TestListDomainsWithNextTokenXmlOK) - - resp, err := s.sdb.ListDomains() - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.ResponseMetadata.RequestId, Equals, "eb13162f-1b95-4511-8b12-489b86acfd28") - c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907) - c.Assert(resp.Domains, DeepEquals, []string{"Domain1-200706011651", "Domain2-200706011652"}) - c.Assert(resp.NextToken, Equals, "TWV0ZXJpbmdUZXN0RG9tYWluMS0yMDA3MDYwMTE2NTY=") - - c.Assert(err, IsNil) -} - -func (s *S) TestDeleteDomainOK(c *C) { - testServer.Response(200, nil, TestDeleteDomainXmlOK) - - domain := s.sdb.Domain("domain") - resp, err := domain.DeleteDomain() - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.ResponseMetadata.RequestId, Equals, "039e1e25-9a64-2a74-93da-2fda36122a97") - c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0055590278) - - c.Assert(err, IsNil) -} - -func (s *S) TestPutAttrsOK(c *C) { - testServer.Response(200, nil, TestPutAttrsXmlOK) - - domain := s.sdb.Domain("MyDomain") - item := domain.Item("Item123") - - putAttrs := new(sdb.PutAttrs) - putAttrs.Add("FirstName", "john") - putAttrs.Add("LastName", "smith") - putAttrs.Replace("MiddleName", "jacob") - - putAttrs.IfValue("FirstName", "john") - putAttrs.IfMissing("FirstName") - - resp, err := item.PutAttrs(putAttrs) - req := testServer.WaitRequest() - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Form["Action"], DeepEquals, []string{"PutAttributes"}) - c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"}) - c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"}) - c.Assert(req.Form["Attribute.1.Name"], DeepEquals, []string{"FirstName"}) - c.Assert(req.Form["Attribute.1.Value"], DeepEquals, []string{"john"}) - c.Assert(req.Form["Attribute.2.Name"], DeepEquals, []string{"LastName"}) - c.Assert(req.Form["Attribute.2.Value"], DeepEquals, []string{"smith"}) - c.Assert(req.Form["Attribute.3.Name"], DeepEquals, []string{"MiddleName"}) - c.Assert(req.Form["Attribute.3.Value"], DeepEquals, []string{"jacob"}) - c.Assert(req.Form["Attribute.3.Replace"], DeepEquals, []string{"true"}) - - c.Assert(req.Form["Expected.1.Name"], DeepEquals, []string{"FirstName"}) - c.Assert(req.Form["Expected.1.Value"], DeepEquals, []string{"john"}) - c.Assert(req.Form["Expected.1.Exists"], DeepEquals, []string{"false"}) - - c.Assert(err, IsNil) - c.Assert(resp.ResponseMetadata.RequestId, Equals, "490206ce-8292-456c-a00f-61b335eb202b") - c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907) - -} - -func (s *S) TestAttrsOK(c *C) { - testServer.Response(200, nil, TestAttrsXmlOK) - - domain := s.sdb.Domain("MyDomain") - item := domain.Item("Item123") - - resp, err := item.Attrs(nil, true) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - c.Assert(req.Form["Action"], DeepEquals, []string{"GetAttributes"}) - c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"}) - c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"}) - c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"}) - - c.Assert(resp.Attrs[0].Name, Equals, "Color") - c.Assert(resp.Attrs[0].Value, Equals, "Blue") - c.Assert(resp.Attrs[1].Name, Equals, "Size") - c.Assert(resp.Attrs[1].Value, Equals, "Med") - c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d") - c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219942) - - c.Assert(err, IsNil) -} - -func (s *S) TestAttrsSelectOK(c *C) { - testServer.Response(200, nil, TestAttrsXmlOK) - - domain := s.sdb.Domain("MyDomain") - item := domain.Item("Item123") - - resp, err := item.Attrs([]string{"Color", "Size"}, true) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - c.Assert(req.Form["Action"], DeepEquals, []string{"GetAttributes"}) - c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"}) - c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"}) - c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"}) - c.Assert(req.Form["AttributeName.1"], DeepEquals, []string{"Color"}) - c.Assert(req.Form["AttributeName.2"], DeepEquals, []string{"Size"}) - - c.Assert(resp.Attrs[0].Name, Equals, "Color") - c.Assert(resp.Attrs[0].Value, Equals, "Blue") - c.Assert(resp.Attrs[1].Name, Equals, "Size") - c.Assert(resp.Attrs[1].Value, Equals, "Med") - c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d") - c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219942) - - c.Assert(err, IsNil) -} - -func (s *S) TestSelectOK(c *C) { - testServer.Response(200, nil, TestSelectXmlOK) - - resp, err := s.sdb.Select("select Color from MyDomain where Color like 'Blue%'", true) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - c.Assert(req.Form["Action"], DeepEquals, []string{"Select"}) - c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"}) - - c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d") - c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907) - c.Assert(len(resp.Items), Equals, 2) - c.Assert(resp.Items[0].Name, Equals, "Item_03") - c.Assert(resp.Items[1].Name, Equals, "Item_06") - c.Assert(resp.Items[0].Attrs[0].Name, Equals, "Category") - c.Assert(resp.Items[0].Attrs[0].Value, Equals, "Clothes") - - c.Assert(err, IsNil) -} diff --git a/vendor/github.com/goamz/goamz/exp/sdb/sign.go b/vendor/github.com/goamz/goamz/exp/sdb/sign.go deleted file mode 100644 index 040ed5385..000000000 --- a/vendor/github.com/goamz/goamz/exp/sdb/sign.go +++ /dev/null @@ -1,54 +0,0 @@ -package sdb - -import ( - "crypto/hmac" - "crypto/sha256" - "encoding/base64" - "github.com/goamz/goamz/aws" - "net/http" - "net/url" - "sort" - "strings" -) - -var b64 = base64.StdEncoding - -// ---------------------------------------------------------------------------- -// SimpleDB signing (http://goo.gl/CaY81) - -func sign(auth aws.Auth, method, path string, params url.Values, headers http.Header) { - var host string - for k, v := range headers { - k = strings.ToLower(k) - switch k { - case "host": - host = v[0] - } - } - - // set up some defaults used for signing the request - params["AWSAccessKeyId"] = []string{auth.AccessKey} - params["SignatureVersion"] = []string{"2"} - params["SignatureMethod"] = []string{"HmacSHA256"} - if auth.Token() != "" { - params["SecurityToken"] = []string{auth.Token()} - } - - // join up all the incoming params - var sarray []string - for k, v := range params { - sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v[0])) - } - sort.StringSlice(sarray).Sort() - joined := strings.Join(sarray, "&") - - // create the payload, sign it and create the signature - payload := strings.Join([]string{method, host, "/", joined}, "\n") - hash := hmac.New(sha256.New, []byte(auth.SecretKey)) - hash.Write([]byte(payload)) - signature := make([]byte, b64.EncodedLen(hash.Size())) - b64.Encode(signature, hash.Sum(nil)) - - // add the signature to the outgoing params - params["Signature"] = []string{string(signature)} -} diff --git a/vendor/github.com/goamz/goamz/exp/sdb/sign_test.go b/vendor/github.com/goamz/goamz/exp/sdb/sign_test.go deleted file mode 100644 index f45ad15e1..000000000 --- a/vendor/github.com/goamz/goamz/exp/sdb/sign_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package sdb_test - -import ( - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/exp/sdb" - . "gopkg.in/check.v1" -) - -// SimpleDB ReST authentication docs: http://goo.gl/CaY81 - -var testAuth = aws.Auth{AccessKey: "access-key-id-s8eBOWuU", SecretKey: "secret-access-key-UkQjTLd9"} - -func (s *S) TestSignExampleDomainCreate(c *C) { - method := "GET" - params := map[string][]string{ - "Action": {"CreateDomain"}, - "DomainName": {"MyDomain"}, - "Timestamp": {"2011-08-20T07:23:57+12:00"}, - "Version": {"2009-04-15"}, - } - headers := map[string][]string{ - "Host": {"sdb.amazonaws.com"}, - } - sdb.Sign(testAuth, method, "", params, headers) - expected := "ot2JaeeqMRJqgAqW67hkzUlffgxdOz4RykbrECB+tDU=" - c.Assert(params["Signature"], DeepEquals, []string{expected}) -} - -// Do a few test methods which takes combinations of params diff --git a/vendor/github.com/goamz/goamz/exp/ses/ses.go b/vendor/github.com/goamz/goamz/exp/ses/ses.go deleted file mode 100644 index 3896c5253..000000000 --- a/vendor/github.com/goamz/goamz/exp/ses/ses.go +++ /dev/null @@ -1,149 +0,0 @@ -// ses.go -package ses - -import ( - "encoding/xml" - "github.com/goamz/goamz/aws" - "io/ioutil" - "net/http" - "net/url" - "strconv" - "strings" -) - -type SES struct { - auth aws.Auth - region aws.Region - client *http.Client -} - -// Initializes a pointer to an SES struct which can be used -// to perform SES API calls. -func NewSES(auth aws.Auth, region aws.Region) *SES { - ses := SES{auth, region, nil} - return &ses -} - -// Sends an email to the specifications stored in the Email struct. -func (ses *SES) SendEmail(email *Email) error { - data := make(url.Values) - - index := 0 - for i := range email.destination.bccAddresses { - if len(email.destination.bccAddresses[i]) > 0 { - index += 1 - key := "Destination.BccAddresses.member." + strconv.Itoa(index) - data.Add(key, email.destination.bccAddresses[i]) - } - } - - index = 0 - for i := range email.destination.ccAddresses { - if len(email.destination.ccAddresses[i]) > 0 { - index += 1 - key := "Destination.CcAddresses.member." + strconv.Itoa(index) - data.Add(key, email.destination.ccAddresses[i]) - } - } - - index = 0 - for i := range email.destination.toAddresses { - if len(email.destination.toAddresses[i]) > 0 { - index += 1 - key := "Destination.ToAddresses.member." + strconv.Itoa(index) - data.Add(key, email.destination.toAddresses[i]) - } - } - - index = 0 - for i := range email.replyTo { - if len(email.replyTo[i]) > 0 { - index += 1 - key := "ReplyToAddresses.member." + strconv.Itoa(index) - data.Add(key, email.replyTo[i]) - } - } - - if len(email.message.Subject.Data) > 0 { - if len(email.message.Subject.Charset) > 0 { - data.Add("Message.Subject.Charset", email.message.Subject.Charset) - } - data.Add("Message.Subject.Data", email.message.Subject.Data) - } - - if len(email.message.Body.Html.Data) > 0 { - if len(email.message.Body.Html.Charset) > 0 { - data.Add("Message.Body.Html.Charset", email.message.Body.Html.Charset) - } - data.Add("Message.Body.Html.Data", email.message.Body.Html.Data) - } - - if len(email.message.Body.Text.Data) > 0 { - if len(email.message.Body.Text.Charset) > 0 { - data.Add("Message.Body.Text.Charset", email.message.Body.Text.Charset) - } - data.Add("Message.Body.Text.Data", email.message.Body.Text.Data) - } - - if len(email.returnPath) > 0 { - data.Add("ReturnPath", email.returnPath) - } - - if len(email.source) > 0 { - data.Add("Source", email.source) - } - - return ses.doPost("SendEmail", data) -} - -// Do an SES POST action. -func (ses *SES) doPost(action string, data url.Values) error { - req := http.Request{ - Method: "POST", - ProtoMajor: 1, - ProtoMinor: 1, - Close: true, - Header: http.Header{}} - - URL, err := url.Parse(ses.region.SESEndpoint) - if err != nil { - return err - } - URL.Path = "/" - - req.URL = URL - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") - token := ses.auth.Token() - if token != "" { - req.Header.Set("X-Amz-Security-Token", token) - } - sign(ses.auth, "POST", req.Header) - - data.Add("AWSAccessKeyId", ses.auth.AccessKey) - data.Add("Action", action) - - body := data.Encode() - req.Header.Add("Content-Length", strconv.Itoa(len(body))) - req.Body = ioutil.NopCloser(strings.NewReader(body)) - - if ses.client == nil { - ses.client = &http.Client{} - } - - resp, err := ses.client.Do(&req) - if err != nil { - return err - } - if resp.StatusCode > 204 { - defer resp.Body.Close() - return buildError(resp) - } - - return nil -} - -func buildError(r *http.Response) *SESError { - rootElem := errorResponse{} - xml.NewDecoder(r.Body).Decode(&rootElem) - return &rootElem.Error -} diff --git a/vendor/github.com/goamz/goamz/exp/ses/ses_test.go b/vendor/github.com/goamz/goamz/exp/ses/ses_test.go deleted file mode 100644 index ae93215ed..000000000 --- a/vendor/github.com/goamz/goamz/exp/ses/ses_test.go +++ /dev/null @@ -1,69 +0,0 @@ -// ses_test -package ses_test - -import ( - "bytes" - "net/url" - "testing" - - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/exp/ses" - "github.com/goamz/goamz/testutil" - . "gopkg.in/check.v1" -) - -func Test(t *testing.T) { - TestingT(t) -} - -type S struct { - ses *ses.SES -} - -var _ = Suite(&S{}) - -var testServer = testutil.NewHTTPServer() - -func (s *S) SetUpSuite(c *C) { - testServer.Start() - auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} - s.ses = ses.NewSES(auth, aws.Region{Name: "faux-region-1", S3Endpoint: testServer.URL}) -} - -func (s *S) TearDownStrategy(c *C) { - -} - -func (s *S) SetUpTest(c *C) { - -} - -func (s *S) TearDownTest(c *C) { - testServer.Flush() -} - -func (s *S) TestSendEmail(c *C) { - testServer.Response(200, nil, "") - - email := ses.NewEmail() - email.AddTo("test@test.com") - email.AddSource("test@test.com") - email.SetSubject("test") - email.SetBodyHtml("test") - - s.ses.SendEmail(email) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "POST") - c.Assert(req.Header["Date"], Not(Equals), "") - - buf := new(bytes.Buffer) - buf.ReadFrom(req.Body) - body, _ := url.ParseQuery(buf.String()) - - c.Assert(body, Not(IsNil)) - c.Assert(body["Destination.ToAddresses.member.1"], Equals, "test@test.com") - c.Assert(body["Source"], Equals, "test@test.com") - c.Assert(body["Message.Subject.Data"], Equals, "test") - c.Assert(body["Message.Body.Html.Data"], Equals, "test") -} diff --git a/vendor/github.com/goamz/goamz/exp/ses/ses_types.go b/vendor/github.com/goamz/goamz/exp/ses/ses_types.go deleted file mode 100644 index d26e83740..000000000 --- a/vendor/github.com/goamz/goamz/exp/ses/ses_types.go +++ /dev/null @@ -1,160 +0,0 @@ -// ses_types -package ses - -// Private internal representation of message body. -type Body struct { - Html Content - Text Content -} - -// Content data structure with charset and payload (Data). -type Content struct { - Charset string - Data string -} - -// Email data structure. Should be main data structure used -// for sending emails using SES. -type Email struct { - destination *destination - message Message - replyTo []string - returnPath string - source string -} - -// Private internal representation for email destinations. -type destination struct { - bccAddresses []string - ccAddresses []string - toAddresses []string -} - -// Message data structure. -type Message struct { - Body Body - Subject Content -} - -// SES Error structure. -type SESError struct { - Type string - Code string - Message string - Detail string - RequestId string -} - -type errorResponse struct { - Error SESError -} - -func (err *SESError) Error() string { - return err.Message -} - -// Returns a pointer to an empty but initialized Email. -func NewEmail() *Email { - return &Email{ - destination: newDestination(), - replyTo: make([]string, 5)} -} - -// Private function to return an initialized destination. -func newDestination() *destination { - return &destination{ - bccAddresses: make([]string, 5), - ccAddresses: make([]string, 5), - toAddresses: make([]string, 5)} -} - -// Add a BCC destination to Email. -func (em *Email) AddBCC(address string) { - em.destination.bccAddresses = append(em.destination.bccAddresses, address) -} - -// Add multiple BCC destinations to Email. -func (em *Email) AddBCCs(addresses []string) { - em.destination.bccAddresses = append(em.destination.bccAddresses, addresses...) -} - -// Add a CC destination to Email. -func (em *Email) AddCC(address string) { - em.destination.ccAddresses = append(em.destination.ccAddresses, address) -} - -// Add multiple CC destinations to Email. -func (em *Email) AddCCs(addresses []string) { - em.destination.ccAddresses = append(em.destination.ccAddresses, addresses...) -} - -// Add a To destination to Email. -func (em *Email) AddTo(address string) { - em.destination.toAddresses = append(em.destination.toAddresses, address) -} - -// Add multiple To destinations to Email. -func (em *Email) AddTos(addresses []string) { - em.destination.toAddresses = append(em.destination.toAddresses, addresses...) -} - -// Add a reply-to address to Email. -func (em *Email) AddReplyTo(address string) { - em.replyTo = append(em.replyTo, address) -} - -// Add multiple reply-to addresses to Email. -func (em *Email) AddReplyTos(addresses []string) { - em.replyTo = append(em.replyTo, addresses...) -} - -// Set the return path for Email. -func (em *Email) SetReturnPath(path string) { - em.returnPath = path -} - -// Set the source address for Email. -func (em *Email) SetSource(source string) { - em.source = source -} - -// Set the Email message. -func (em *Email) SetMessage(message Message) { - em.message = message -} - -// Set the subject for the Email message. -// Uses ASCII as charset. -func (em *Email) SetSubject(subject string) { - em.message.Subject = Content{Data: subject} -} - -// Set the subject for the Email message. -// Uses the charset (or ASCII if none) of Content. -func (em *Email) SetSubjectAsContent(subject Content) { - em.message.Subject = subject -} - -// Sets the HTML body of the Email message. -// Uses ASCII as charset. -func (em *Email) SetBodyHtml(html string) { - em.message.Body.Html = Content{Data: html} -} - -// Sets the HTML body of the Email message. -// Uses the charset (or ASCII if none) of Content. -func (em *Email) SetBodyHtmlAsContent(html Content) { - em.message.Body.Html = html -} - -// Sets the raw text body of the Email message. -// Uses ASCII as charset. -func (em *Email) SetBodyRawText(text string) { - em.message.Body.Text = Content{Data: text} -} - -// Sets the raw test body of the Email message. -// Uses the charset (or ASCII if none) of Content. -func (em *Email) SetBodyRawTextAsContent(text Content) { - em.message.Body.Text = text -} diff --git a/vendor/github.com/goamz/goamz/exp/ses/sign.go b/vendor/github.com/goamz/goamz/exp/ses/sign.go deleted file mode 100644 index 5c9c840c8..000000000 --- a/vendor/github.com/goamz/goamz/exp/ses/sign.go +++ /dev/null @@ -1,26 +0,0 @@ -// sign -package ses - -import ( - "crypto/hmac" - "crypto/sha256" - "encoding/base64" - "fmt" - "github.com/goamz/goamz/aws" - "time" -) - -const ( - AMZ_DATE_STYLE = "Mon, 02 Jan 2006 15:04:05 -0700" -) - -// Sign SES request as dictated by Amazon's Version 3 signature method. -func sign(auth aws.Auth, method string, headers map[string][]string) { - date := time.Now().UTC().Format(AMZ_DATE_STYLE) - h := hmac.New(sha256.New, []byte(auth.SecretKey)) - h.Write([]byte(date)) - signature := base64.StdEncoding.EncodeToString(h.Sum(nil)) - authHeader := fmt.Sprintf("AWS3-HTTPS AWSAccessKeyId=%s, Algorithm=HmacSHA256, Signature=%s", auth.AccessKey, signature) - headers["Date"] = []string{date} - headers["X-Amzn-Authorization"] = []string{authHeader} -} diff --git a/vendor/github.com/goamz/goamz/exp/sns/Makefile b/vendor/github.com/goamz/goamz/exp/sns/Makefile deleted file mode 100644 index 1e5b9da3b..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -include $(GOROOT)/src/Make.inc - -TARG=launchpad.net/goamz/sns - -GOFILES=\ - sns.go\ - sign.go\ - -include $(GOROOT)/src/Make.pkg - -GOFMT=gofmt -BADFMT=$(shell $(GOFMT) -l $(GOFILES) 2> /dev/null) - -gofmt: $(BADFMT) - @for F in $(BADFMT); do $(GOFMT) -w $$F && echo $$F; done - -ifneq ($(BADFMT),) -ifneq ($(MAKECMDGOALS), gofmt) -#$(warning WARNING: make gofmt: $(BADFMT)) -endif -endif diff --git a/vendor/github.com/goamz/goamz/exp/sns/README b/vendor/github.com/goamz/goamz/exp/sns/README deleted file mode 100644 index 87770adb5..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/README +++ /dev/null @@ -1 +0,0 @@ -Amazon Simple Notification Service API for Golang. diff --git a/vendor/github.com/goamz/goamz/exp/sns/endpoint.go b/vendor/github.com/goamz/goamz/exp/sns/endpoint.go deleted file mode 100644 index c6e6e4433..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/endpoint.go +++ /dev/null @@ -1,132 +0,0 @@ -package sns - -import ( - "fmt" - "strconv" -) - -type DeleteEndpointResponse struct { - ResponseMetadata -} - -type GetEndpointAttributesResponse struct { - Attributes []AttributeEntry `xml:"GetEndpointAttributesResult>Attributes>entry"` - ResponseMetadata -} - -type PlatformEndpointOpt struct { - Attributes []AttributeEntry - PlatformApplicationArn string - CustomUserData string - Token string -} - -type CreatePlatformEndpointResponse struct { - EndpointArn string `xml:"CreatePlatformEndpointResult>EndpointArn"` - ResponseMetadata -} - -type PlatformEndpoints struct { - EndpointArn string `xml:"EndpointArn"` - Attributes []AttributeEntry `xml:"Attributes>entry"` -} - -type ListEndpointsByPlatformApplicationResponse struct { - Endpoints []PlatformEndpoints `xml:"ListEndpointsByPlatformApplicationResult>Endpoints>member"` - ResponseMetadata -} - -type SetEndpointAttributesOpt struct { - Attributes []AttributeEntry - EndpointArn string -} - -type SetEndpointAttributesResponse struct { - ResponseMetadata -} - -// DeleteEndpoint -// -// See http://goo.gl/9SlUD9 for more details. -func (sns *SNS) DeleteEndpoint(endpointArn string) (resp *DeleteEndpointResponse, err error) { - resp = &DeleteEndpointResponse{} - params := makeParams("DeleteEndpoint") - - params["EndpointArn"] = endpointArn - - err = sns.query(params, resp) - - return -} - -// GetEndpointAttributes -// -// See http://goo.gl/c8E5X1 for more details. -func (sns *SNS) GetEndpointAttributes(endpointArn string) (resp *GetEndpointAttributesResponse, err error) { - resp = &GetEndpointAttributesResponse{} - - params := makeParams("GetEndpointAttributes") - - params["EndpointArn"] = endpointArn - - err = sns.query(params, resp) - - return -} - -// CreatePlatformEndpoint -// -// See http://goo.gl/4tnngi for more details. -func (sns *SNS) CreatePlatformEndpoint(options *PlatformEndpointOpt) (resp *CreatePlatformEndpointResponse, err error) { - - resp = &CreatePlatformEndpointResponse{} - params := makeParams("CreatePlatformEndpoint") - - params["PlatformApplicationArn"] = options.PlatformApplicationArn - params["Token"] = options.Token - - if options.CustomUserData != "" { - params["CustomUserData"] = options.CustomUserData - } - - err = sns.query(params, resp) - - return -} - -// ListEndpointsByPlatformApplication -// -// See http://goo.gl/L7ioyR for more detail. -func (sns *SNS) ListEndpointsByPlatformApplication(platformApplicationArn, nextToken string) (resp *ListEndpointsByPlatformApplicationResponse, err error) { - resp = &ListEndpointsByPlatformApplicationResponse{} - - params := makeParams("ListEndpointsByPlatformApplication") - - params["PlatformApplicationArn"] = platformApplicationArn - - if nextToken != "" { - params["NextToken"] = nextToken - } - - err = sns.query(params, resp) - return - -} - -// SetEndpointAttributes -// -// See http://goo.gl/GTktCj for more detail. -func (sns *SNS) SetEndpointAttributes(options *SetEndpointAttributesOpt) (resp *SetEndpointAttributesResponse, err error) { - resp = &SetEndpointAttributesResponse{} - params := makeParams("SetEndpointAttributes") - - params["EndpointArn"] = options.EndpointArn - - for i, attr := range options.Attributes { - params[fmt.Sprintf("Attributes.entry.%s.key", strconv.Itoa(i+1))] = attr.Key - params[fmt.Sprintf("Attributes.entry.%s.value", strconv.Itoa(i+1))] = attr.Value - } - - err = sns.query(params, resp) - return -} diff --git a/vendor/github.com/goamz/goamz/exp/sns/permissions.go b/vendor/github.com/goamz/goamz/exp/sns/permissions.go deleted file mode 100644 index e7c73629f..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/permissions.go +++ /dev/null @@ -1,51 +0,0 @@ -package sns - -import ( - "strconv" -) - -type Permission struct { - ActionName string - AccountId string -} - -type AddPermissionResponse struct { - ResponseMetadata -} - -// AddPermission -// -// See http://goo.gl/mbY4a for more details. -func (sns *SNS) AddPermission(permissions []Permission, Label, TopicArn string) (resp *AddPermissionResponse, err error) { - resp = &AddPermissionResponse{} - params := makeParams("AddPermission") - - for i, p := range permissions { - params["AWSAccountId.member."+strconv.Itoa(i+1)] = p.AccountId - params["ActionName.member."+strconv.Itoa(i+1)] = p.ActionName - } - - params["Label"] = Label - params["TopicArn"] = TopicArn - - err = sns.query(params, resp) - return -} - -type RemovePermissionResponse struct { - ResponseMetadata -} - -// RemovePermission -// -// See http://goo.gl/wGl5j for more details. -func (sns *SNS) RemovePermission(Label, TopicArn string) (resp *RemovePermissionResponse, err error) { - resp = &RemovePermissionResponse{} - params := makeParams("RemovePermission") - - params["Label"] = Label - params["TopicArn"] = TopicArn - - err = sns.query(params, resp) - return -} diff --git a/vendor/github.com/goamz/goamz/exp/sns/platform.go b/vendor/github.com/goamz/goamz/exp/sns/platform.go deleted file mode 100644 index b650cdda7..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/platform.go +++ /dev/null @@ -1,135 +0,0 @@ -package sns - -import ( - "fmt" - "strconv" -) - -type CreatePlatformApplicationResponse struct { - PlatformApplicationArn string `xml:"CreatePlatformApplicationResult>PlatformApplicationArn"` - ResponseMetadata -} - -type PlatformApplicationOpt struct { - Attributes []AttributeEntry - Name string - Platform string -} - -type DeletePlatformApplicationResponse struct { - ResponseMetadata -} - -type GetPlatformApplicationAttributesResponse struct { - Attributes []AttributeEntry `xml:"GetPlatformApplicationAttributesResult>Attributes>entry"` - ResponseMetadata -} - -type SetPlatformApplicationAttributesOpt struct { - Attributes []AttributeEntry - PlatformApplicationArn string -} - -type SetPlatformApplicationAttributesResponse struct { - ResponseMetadata -} - -type PlatformApplication struct { - Attributes []AttributeEntry `xml:"Attributes>entry"` - PlatformApplicationArn string -} - -type ListPlatformApplicationsResponse struct { - NextToken string - PlatformApplications []PlatformApplication `xml:"ListPlatformApplicationsResult>PlatformApplications>member"` - ResponseMetadata -} - -// CreatePlatformApplication -// -// See http://goo.gl/Mbbl6Z for more details. - -func (sns *SNS) CreatePlatformApplication(options *PlatformApplicationOpt) (resp *CreatePlatformApplicationResponse, err error) { - resp = &CreatePlatformApplicationResponse{} - params := makeParams("CreatePlatformApplication") - - params["Platform"] = options.Platform - params["Name"] = options.Name - - for i, attr := range options.Attributes { - params[fmt.Sprintf("Attributes.entry.%s.key", strconv.Itoa(i+1))] = attr.Key - params[fmt.Sprintf("Attributes.entry.%s.value", strconv.Itoa(i+1))] = attr.Value - } - - err = sns.query(params, resp) - - return - -} - -// DeletePlatformApplication -// -// See http://goo.gl/6GB3DN for more details. -func (sns *SNS) DeletePlatformApplication(platformApplicationArn string) (resp *DeletePlatformApplicationResponse, err error) { - resp = &DeletePlatformApplicationResponse{} - - params := makeParams("DeletePlatformApplication") - - params["PlatformApplicationArn"] = platformApplicationArn - - err = sns.query(params, resp) - - return -} - -// GetPlatformApplicationAttributes -// -// See http://goo.gl/GswJ8I for more details. -func (sns *SNS) GetPlatformApplicationAttributes(platformApplicationArn, nextToken string) (resp *GetPlatformApplicationAttributesResponse, err error) { - resp = &GetPlatformApplicationAttributesResponse{} - - params := makeParams("GetPlatformApplicationAttributes") - - params["PlatformApplicationArn"] = platformApplicationArn - - if nextToken != "" { - params["NextToken"] = nextToken - } - - err = sns.query(params, resp) - - return -} - -// ListPlatformApplications -// -// See http://goo.gl/vQ3ooV for more detail. -func (sns *SNS) ListPlatformApplications(nextToken string) (resp *ListPlatformApplicationsResponse, err error) { - resp = &ListPlatformApplicationsResponse{} - params := makeParams("ListPlatformApplications") - - if nextToken != "" { - params["NextToken"] = nextToken - } - - err = sns.query(params, resp) - return -} - -// SetPlatformApplicationAttributes -// -// See http://goo.gl/RWnzzb for more detail. -func (sns *SNS) SetPlatformApplicationAttributes(options *SetPlatformApplicationAttributesOpt) (resp *SetPlatformApplicationAttributesResponse, err error) { - resp = &SetPlatformApplicationAttributesResponse{} - params := makeParams("SetPlatformApplicationAttributes") - - params["PlatformApplicationArn"] = options.PlatformApplicationArn - - for i, attr := range options.Attributes { - params[fmt.Sprintf("Attributes.entry.%s.key", strconv.Itoa(i+1))] = attr.Key - params[fmt.Sprintf("Attributes.entry.%s.value", strconv.Itoa(i+1))] = attr.Value - } - - err = sns.query(params, resp) - return -} diff --git a/vendor/github.com/goamz/goamz/exp/sns/responses_test.go b/vendor/github.com/goamz/goamz/exp/sns/responses_test.go deleted file mode 100644 index 53a06429d..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/responses_test.go +++ /dev/null @@ -1,317 +0,0 @@ -package sns_test - -var TestListTopicsXmlOK = ` -<?xml version="1.0"?> -<ListTopicsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ListTopicsResult> - <Topics> - <member> - <TopicArn>arn:aws:sns:us-west-1:331995417492:Transcoding</TopicArn> - </member> - </Topics> - </ListTopicsResult> - <ResponseMetadata> - <RequestId>bd10b26c-e30e-11e0-ba29-93c3aca2f103</RequestId> - </ResponseMetadata> -</ListTopicsResponse> -` - -var TestCreateTopicXmlOK = ` -<?xml version="1.0"?> -<CreateTopicResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <CreateTopicResult> - <TopicArn>arn:aws:sns:us-east-1:123456789012:My-Topic</TopicArn> - </CreateTopicResult> - <ResponseMetadata> - <RequestId>a8dec8b3-33a4-11df-8963-01868b7c937a</RequestId> - </ResponseMetadata> -</CreateTopicResponse> -` - -var TestDeleteTopicXmlOK = ` -<DeleteTopicResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>f3aa9ac9-3c3d-11df-8235-9dab105e9c32</RequestId> - </ResponseMetadata> -</DeleteTopicResponse> -` - -var TestListSubscriptionsXmlOK = ` -<ListSubscriptionsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ListSubscriptionsResult> - <Subscriptions> - <member> - <TopicArn>arn:aws:sns:us-east-1:698519295917:My-Topic</TopicArn> - <Protocol>email</Protocol> - <SubscriptionArn>arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca</SubscriptionArn> - <Owner>123456789012</Owner> - <Endpoint>example@amazon.com</Endpoint> - </member> - </Subscriptions> - </ListSubscriptionsResult> - <ResponseMetadata> - <RequestId>384ac68d-3775-11df-8963-01868b7c937a</RequestId> - </ResponseMetadata> -</ListSubscriptionsResponse> -` - -var TestGetTopicAttributesXmlOK = ` -<GetTopicAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <GetTopicAttributesResult> - <Attributes> - <entry> - <key>Owner</key> - <value>123456789012</value> - </entry> - <entry> - <key>Policy</key> - <value>{"Version":"2008-10-17","Id":"us-east-1/698519295917/test__default_policy_ID","Statement" : [{"Effect":"Allow","Sid":"us-east-1/698519295917/test__default_statement_ID","Principal" : {"AWS": "*"},"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],"Resource":"arn:aws:sns:us-east-1:698519295917:test","Condition" : {"StringLike" : {"AWS:SourceArn": "arn:aws:*:*:698519295917:*"}}}]}</value> - </entry> - <entry> - <key>TopicArn</key> - <value>arn:aws:sns:us-east-1:123456789012:My-Topic</value> - </entry> - </Attributes> - </GetTopicAttributesResult> - <ResponseMetadata> - <RequestId>057f074c-33a7-11df-9540-99d0768312d3</RequestId> - </ResponseMetadata> -</GetTopicAttributesResponse> -` - -var TestPublishXmlOK = ` -<PublishResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <PublishResult> - <MessageId>94f20ce6-13c5-43a0-9a9e-ca52d816e90b</MessageId> - </PublishResult> - <ResponseMetadata> - <RequestId>f187a3c1-376f-11df-8963-01868b7c937a</RequestId> - </ResponseMetadata> -</PublishResponse> -` - -var TestSetTopicAttributesXmlOK = ` -<SetTopicAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>a8763b99-33a7-11df-a9b7-05d48da6f042</RequestId> - </ResponseMetadata> -</SetTopicAttributesResponse> -` - -var TestSubscribeXmlOK = ` -<SubscribeResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <SubscribeResult> - <SubscriptionArn>pending confirmation</SubscriptionArn> - </SubscribeResult> - <ResponseMetadata> - <RequestId>a169c740-3766-11df-8963-01868b7c937a</RequestId> - </ResponseMetadata> -</SubscribeResponse> -` - -var TestUnsubscribeXmlOK = ` -<UnsubscribeResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>18e0ac39-3776-11df-84c0-b93cc1666b84</RequestId> - </ResponseMetadata> -</UnsubscribeResponse> -` - -var TestConfirmSubscriptionXmlOK = ` -<ConfirmSubscriptionResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ConfirmSubscriptionResult> - <SubscriptionArn>arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca</SubscriptionArn> - </ConfirmSubscriptionResult> - <ResponseMetadata> - <RequestId>7a50221f-3774-11df-a9b7-05d48da6f042</RequestId> - </ResponseMetadata> -</ConfirmSubscriptionResponse> -` - -var TestAddPermissionXmlOK = ` -<AddPermissionResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>6a213e4e-33a8-11df-9540-99d0768312d3</RequestId> - </ResponseMetadata> -</AddPermissionResponse> -` - -var TestRemovePermissionXmlOK = ` -<RemovePermissionResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>d170b150-33a8-11df-995a-2d6fbe836cc1</RequestId> - </ResponseMetadata> -</RemovePermissionResponse> -` - -var TestListSubscriptionsByTopicXmlOK = ` -<ListSubscriptionsByTopicResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ListSubscriptionsByTopicResult> - <Subscriptions> - <member> - <TopicArn>arn:aws:sns:us-east-1:123456789012:My-Topic</TopicArn> - <Protocol>email</Protocol> - <SubscriptionArn>arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca</SubscriptionArn> - <Owner>123456789012</Owner> - <Endpoint>example@amazon.com</Endpoint> - </member> - </Subscriptions> - </ListSubscriptionsByTopicResult> - <ResponseMetadata> - <RequestId>b9275252-3774-11df-9540-99d0768312d3</RequestId> - </ResponseMetadata> -</ListSubscriptionsByTopicResponse> -` - -var TestCreatePlatformApplicationXmlOK = ` -<CreatePlatformApplicationResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <CreatePlatformApplicationResult> - <PlatformApplicationArn>arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp</PlatformApplicationArn> - </CreatePlatformApplicationResult> - <ResponseMetadata> - <RequestId>b6f0e78b-e9d4-5a0e-b973-adc04e8a4ff9</RequestId> - </ResponseMetadata> -</CreatePlatformApplicationResponse> -` - -var TestCreatePlatformEndpointXmlOK = ` -<CreatePlatformEndpointResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <CreatePlatformEndpointResult> - <EndpointArn>arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3</EndpointArn> - </CreatePlatformEndpointResult> - <ResponseMetadata> - <RequestId>6613341d-3e15-53f7-bf3c-7e56994ba278</RequestId> - </ResponseMetadata> -</CreatePlatformEndpointResponse> -` - -var DeleteEndpointXmlOK = ` -<DeleteEndpointResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>c1d2b191-353c-5a5f-8969-fbdd3900afa8</RequestId> - </ResponseMetadata> -</DeleteEndpointResponse> -` - -var TestDeletePlatformApplicationXmlOK = ` -<DeletePlatformApplicationResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>097dac18-7a77-5823-a8dd-e65476dcb037</RequestId> - </ResponseMetadata> -</DeletePlatformApplicationResponse> -` - -var TestGetEndpointAttributesXmlOK = ` -<GetEndpointAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <GetEndpointAttributesResult> - <Attributes> - <entry> - <key>Enabled</key> - <value>true</value> - </entry> - <entry> - <key>CustomUserData</key> - <value>UserId=01234567</value> - </entry> - <entry> - <key>Token</key> - <value>APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE</value> - </entry> - </Attributes> - </GetEndpointAttributesResult> - <ResponseMetadata> - <RequestId>6c725a19-a142-5b77-94f9-1055a9ea04e7</RequestId> - </ResponseMetadata> -</GetEndpointAttributesResponse> -` - -var TestGetPlatformApplicationAttributesXmlOK = ` -<GetPlatformApplicationAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <GetPlatformApplicationAttributesResult> - <Attributes> - <entry> - <key>AllowEndpointPolicies</key> - <value>false</value> - </entry> - </Attributes> - </GetPlatformApplicationAttributesResult> - <ResponseMetadata> - <RequestId>74848df2-87f6-55ed-890c-c7be80442462</RequestId> - </ResponseMetadata> -</GetPlatformApplicationAttributesResponse> -` - -var TestListEndpointsByPlatformApplicationXmlOK = ` -<ListEndpointsByPlatformApplicationResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ListEndpointsByPlatformApplicationResult> - <Endpoints> - <member> - <EndpointArn>arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3</EndpointArn> - <Attributes> - <entry> - <key>Enabled</key> - <value>true</value> - </entry> - <entry> - <key>CustomUserData</key> - <value>UserId=27576823</value> - </entry> - <entry> - <key>Token</key> - <value>APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE</value> - </entry> - </Attributes> - </member> - </Endpoints> - </ListEndpointsByPlatformApplicationResult> - <ResponseMetadata> - <RequestId>9a48768c-dac8-5a60-aec0-3cc27ea08d96</RequestId> - </ResponseMetadata> -</ListEndpointsByPlatformApplicationResponse> -` - -var TestListPlatformApplicationsXmlOK = ` -<ListPlatformApplicationsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ListPlatformApplicationsResult> - <PlatformApplications> - <member> - <PlatformApplicationArn>arn:aws:sns:us-west-2:123456789012:app/APNS_SANDBOX/apnspushapp</PlatformApplicationArn> - <Attributes> - <entry> - <key>AllowEndpointPolicies</key> - <value>false</value> - </entry> - </Attributes> - </member> - <member> - <PlatformApplicationArn>arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp</PlatformApplicationArn> - <Attributes> - <entry> - <key>AllowEndpointPolicies</key> - <value>false</value> - </entry> - </Attributes> - </member> - </PlatformApplications> - </ListPlatformApplicationsResult> - <ResponseMetadata> - <RequestId>315a335e-85d8-52df-9349-791283cbb529</RequestId> - </ResponseMetadata> -</ListPlatformApplicationsResponse> -` - -var TestSetEndpointAttributesXmlOK = ` -<SetEndpointAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>2fe0bfc7-3e85-5ee5-a9e2-f58b35e85f6a</RequestId> - </ResponseMetadata> -</SetEndpointAttributesResponse> -` - -var TestSetPlatformApplicationAttributesXmlOK = ` -<SetPlatformApplicationAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> - <ResponseMetadata> - <RequestId>cf577bcc-b3dc-5463-88f1-3180b9412395</RequestId> - </ResponseMetadata> -</SetPlatformApplicationAttributesResponse> -` diff --git a/vendor/github.com/goamz/goamz/exp/sns/sign.go b/vendor/github.com/goamz/goamz/exp/sns/sign.go deleted file mode 100644 index 0c35f05ae..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/sign.go +++ /dev/null @@ -1,72 +0,0 @@ -package sns - -import ( - "crypto/hmac" - "crypto/sha256" - "encoding/base64" - "github.com/goamz/goamz/aws" - "sort" - "strings" -) - -var b64 = base64.StdEncoding - -/* -func sign(auth aws.Auth, method, path string, params url.Values, headers http.Header) { - var host string - for k, v := range headers { - k = strings.ToLower(k) - switch k { - case "host": - host = v[0] - } - } - - params["AWSAccessKeyId"] = []string{auth.AccessKey} - params["SignatureVersion"] = []string{"2"} - params["SignatureMethod"] = []string{"HmacSHA256"} - if auth.Token() != "" { - params["SecurityToken"] = auth.Token() - } - - var sarry []string - for k, v := range params { - sarry = append(sarry, aws.Encode(k) + "=" + aws.Encode(v[0])) - } - - sort.StringSlice(sarry).Sort() - joined := strings.Join(sarry, "&") - - payload := strings.Join([]string{method, host, "/", joined}, "\n") - hash := hmac.NewSHA256([]byte(auth.SecretKey)) - hash.Write([]byte(payload)) - signature := make([]byte, b64.EncodedLen(hash.Size())) - b64.Encode(signature, hash.Sum()) - - params["Signature"] = []string{"AWS " + string(signature)} - println("Payload:", payload) - println("Signature:", strings.Join(params["Signature"], "|")) -}*/ - -func sign(auth aws.Auth, method, path string, params map[string]string, host string) { - params["AWSAccessKeyId"] = auth.AccessKey - if auth.Token() != "" { - params["SecurityToken"] = auth.Token() - } - params["SignatureVersion"] = "2" - params["SignatureMethod"] = "HmacSHA256" - - var sarray []string - for k, v := range params { - sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v)) - } - sort.StringSlice(sarray).Sort() - joined := strings.Join(sarray, "&") - payload := method + "\n" + host + "\n" + path + "\n" + joined - hash := hmac.New(sha256.New, []byte(auth.SecretKey)) - hash.Write([]byte(payload)) - signature := make([]byte, b64.EncodedLen(hash.Size())) - b64.Encode(signature, hash.Sum(nil)) - - params["Signature"] = string(signature) -} diff --git a/vendor/github.com/goamz/goamz/exp/sns/sns.go b/vendor/github.com/goamz/goamz/exp/sns/sns.go deleted file mode 100644 index 4d4622211..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/sns.go +++ /dev/null @@ -1,113 +0,0 @@ -// -// goamz - Go packages to interact with the Amazon Web Services. -// -// https://wiki.ubuntu.com/goamz -// -// Copyright (c) 2011 Memeo Inc. -// -// Written by Prudhvi Krishna Surapaneni <me@prudhvi.net> - -// This package is in an experimental state, and does not currently -// follow conventions and style of the rest of goamz or common -// Go conventions. It must be polished before it's considered a -// first-class package in goamz. -package sns - -// BUG(niemeyer): Package needs documentation. - -import ( - "encoding/xml" - "net/http" - "net/url" - "time" - - "github.com/goamz/goamz/aws" -) - -// The SNS type encapsulates operation with an SNS region. -type SNS struct { - aws.Auth - aws.Region - private byte // Reserve the right of using private data. -} - -type AttributeEntry struct { - Key string `xml:"key"` - Value string `xml:"value"` -} - -type ResponseMetadata struct { - RequestId string `xml:"ResponseMetadata>RequestId"` - BoxUsage float64 `xml:"ResponseMetadata>BoxUsage"` -} - -func New(auth aws.Auth, region aws.Region) *SNS { - return &SNS{auth, region, 0} -} - -func makeParams(action string) map[string]string { - params := make(map[string]string) - params["Action"] = action - return params -} - -type Error struct { - StatusCode int - Code string - Message string - RequestId string -} - -func (err *Error) Error() string { - return err.Message -} - -type xmlErrors struct { - RequestId string - Errors []Error `xml:"Errors>Error"` -} - -func (sns *SNS) query(params map[string]string, resp interface{}) error { - params["Timestamp"] = time.Now().UTC().Format(time.RFC3339) - u, err := url.Parse(sns.Region.SNSEndpoint) - if err != nil { - return err - } - - sign(sns.Auth, "GET", "/", params, u.Host) - u.RawQuery = multimap(params).Encode() - r, err := http.Get(u.String()) - if err != nil { - return err - } - defer r.Body.Close() - - if r.StatusCode != 200 { - return buildError(r) - } - err = xml.NewDecoder(r.Body).Decode(resp) - return err -} - -func buildError(r *http.Response) error { - errors := xmlErrors{} - xml.NewDecoder(r.Body).Decode(&errors) - var err Error - if len(errors.Errors) > 0 { - err = errors.Errors[0] - } - err.RequestId = errors.RequestId - err.StatusCode = r.StatusCode - if err.Message == "" { - err.Message = r.Status - } - return &err -} - -func multimap(p map[string]string) url.Values { - q := make(url.Values, len(p)) - for k, v := range p { - q[k] = []string{v} - } - return q -} diff --git a/vendor/github.com/goamz/goamz/exp/sns/sns_test.go b/vendor/github.com/goamz/goamz/exp/sns/sns_test.go deleted file mode 100644 index 054db13d3..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/sns_test.go +++ /dev/null @@ -1,455 +0,0 @@ -package sns_test - -import ( - "testing" - - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/exp/sns" - "github.com/goamz/goamz/testutil" - . "gopkg.in/check.v1" -) - -func Test(t *testing.T) { - TestingT(t) -} - -var _ = Suite(&S{}) - -type S struct { - sns *sns.SNS -} - -var testServer = testutil.NewHTTPServer() - -func (s *S) SetUpSuite(c *C) { - testServer.Start() - auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} - s.sns = sns.New(auth, aws.Region{SNSEndpoint: testServer.URL}) -} - -func (s *S) TearDownTest(c *C) { - testServer.Flush() -} - -func (s *S) TestListTopicsOK(c *C) { - testServer.Response(200, nil, TestListTopicsXmlOK) - - resp, err := s.sns.ListTopics(nil) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.Topics[0].SNS, Equals, s.sns) - c.Assert(resp.ResponseMetadata.RequestId, Equals, "bd10b26c-e30e-11e0-ba29-93c3aca2f103") - c.Assert(err, IsNil) -} - -func (s *S) TestCreateTopic(c *C) { - testServer.Response(200, nil, TestCreateTopicXmlOK) - - resp, err := s.sns.CreateTopic("My-Topic") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.Topic.SNS, Equals, s.sns) - c.Assert(resp.Topic.TopicArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic") - c.Assert(resp.ResponseMetadata.RequestId, Equals, "a8dec8b3-33a4-11df-8963-01868b7c937a") - c.Assert(err, IsNil) -} - -func (s *S) TestDeleteTopic(c *C) { - testServer.Response(200, nil, TestDeleteTopicXmlOK) - - t := sns.Topic{s.sns, "arn:aws:sns:us-east-1:123456789012:My-Topic"} - resp, err := t.Delete() - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.ResponseMetadata.RequestId, Equals, "f3aa9ac9-3c3d-11df-8235-9dab105e9c32") - c.Assert(err, IsNil) -} - -func (s *S) TestListSubscriptions(c *C) { - testServer.Response(200, nil, TestListSubscriptionsXmlOK) - - resp, err := s.sns.ListSubscriptions(nil) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(len(resp.Subscriptions), Not(Equals), 0) - c.Assert(resp.Subscriptions[0].Protocol, Equals, "email") - c.Assert(resp.Subscriptions[0].Endpoint, Equals, "example@amazon.com") - c.Assert(resp.Subscriptions[0].SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca") - c.Assert(resp.Subscriptions[0].TopicArn, Equals, "arn:aws:sns:us-east-1:698519295917:My-Topic") - c.Assert(resp.Subscriptions[0].Owner, Equals, "123456789012") - c.Assert(err, IsNil) -} - -func (s *S) TestGetTopicAttributes(c *C) { - testServer.Response(200, nil, TestGetTopicAttributesXmlOK) - - resp, err := s.sns.GetTopicAttributes("arn:aws:sns:us-east-1:123456789012:My-Topic") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(len(resp.Attributes), Not(Equals), 0) - c.Assert(resp.Attributes[0].Key, Equals, "Owner") - c.Assert(resp.Attributes[0].Value, Equals, "123456789012") - c.Assert(resp.Attributes[1].Key, Equals, "Policy") - c.Assert(resp.Attributes[1].Value, Equals, `{"Version":"2008-10-17","Id":"us-east-1/698519295917/test__default_policy_ID","Statement" : [{"Effect":"Allow","Sid":"us-east-1/698519295917/test__default_statement_ID","Principal" : {"AWS": "*"},"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],"Resource":"arn:aws:sns:us-east-1:698519295917:test","Condition" : {"StringLike" : {"AWS:SourceArn": "arn:aws:*:*:698519295917:*"}}}]}`) - c.Assert(resp.ResponseMetadata.RequestId, Equals, "057f074c-33a7-11df-9540-99d0768312d3") - c.Assert(err, IsNil) -} - -func (s *S) TestPublish(c *C) { - testServer.Response(200, nil, TestPublishXmlOK) - - pubOpt := &sns.PublishOpt{"foobar", "", "subject", "arn:aws:sns:us-east-1:123456789012:My-Topic"} - resp, err := s.sns.Publish(pubOpt) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.MessageId, Equals, "94f20ce6-13c5-43a0-9a9e-ca52d816e90b") - c.Assert(resp.ResponseMetadata.RequestId, Equals, "f187a3c1-376f-11df-8963-01868b7c937a") - c.Assert(err, IsNil) -} - -func (s *S) TestSetTopicAttributes(c *C) { - testServer.Response(200, nil, TestSetTopicAttributesXmlOK) - - resp, err := s.sns.SetTopicAttributes("DisplayName", "MyTopicName", "arn:aws:sns:us-east-1:123456789012:My-Topic") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.ResponseMetadata.RequestId, Equals, "a8763b99-33a7-11df-a9b7-05d48da6f042") - c.Assert(err, IsNil) -} - -func (s *S) TestSubscribe(c *C) { - testServer.Response(200, nil, TestSubscribeXmlOK) - - resp, err := s.sns.Subscribe("example@amazon.com", "email", "arn:aws:sns:us-east-1:123456789012:My-Topic") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.SubscriptionArn, Equals, "pending confirmation") - c.Assert(resp.ResponseMetadata.RequestId, Equals, "a169c740-3766-11df-8963-01868b7c937a") - c.Assert(err, IsNil) -} - -func (s *S) TestUnsubscribe(c *C) { - testServer.Response(200, nil, TestUnsubscribeXmlOK) - - resp, err := s.sns.Unsubscribe("arn:aws:sns:us-east-1:123456789012:My-Topic:a169c740-3766-11df-8963-01868b7c937a") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.ResponseMetadata.RequestId, Equals, "18e0ac39-3776-11df-84c0-b93cc1666b84") - c.Assert(err, IsNil) -} - -func (s *S) TestConfirmSubscription(c *C) { - testServer.Response(200, nil, TestConfirmSubscriptionXmlOK) - - opt := &sns.ConfirmSubscriptionOpt{"", "51b2ff3edb475b7d91550e0ab6edf0c1de2a34e6ebaf6", "arn:aws:sns:us-east-1:123456789012:My-Topic"} - resp, err := s.sns.ConfirmSubscription(opt) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca") - c.Assert(resp.ResponseMetadata.RequestId, Equals, "7a50221f-3774-11df-a9b7-05d48da6f042") - c.Assert(err, IsNil) -} - -func (s *S) TestAddPermission(c *C) { - testServer.Response(200, nil, TestAddPermissionXmlOK) - perm := make([]sns.Permission, 2) - perm[0].ActionName = "Publish" - perm[1].ActionName = "GetTopicAttributes" - perm[0].AccountId = "987654321000" - perm[1].AccountId = "876543210000" - - resp, err := s.sns.AddPermission(perm, "NewPermission", "arn:aws:sns:us-east-1:123456789012:My-Topic") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.RequestId, Equals, "6a213e4e-33a8-11df-9540-99d0768312d3") - c.Assert(err, IsNil) -} - -func (s *S) TestRemovePermission(c *C) { - testServer.Response(200, nil, TestRemovePermissionXmlOK) - - resp, err := s.sns.RemovePermission("NewPermission", "arn:aws:sns:us-east-1:123456789012:My-Topic") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.RequestId, Equals, "d170b150-33a8-11df-995a-2d6fbe836cc1") - c.Assert(err, IsNil) -} - -func (s *S) TestListSubscriptionByTopic(c *C) { - testServer.Response(200, nil, TestListSubscriptionsByTopicXmlOK) - - opt := &sns.ListSubscriptionByTopicOpt{"", "arn:aws:sns:us-east-1:123456789012:My-Topic"} - resp, err := s.sns.ListSubscriptionByTopic(opt) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(len(resp.Subscriptions), Not(Equals), 0) - c.Assert(resp.Subscriptions[0].TopicArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic") - c.Assert(resp.Subscriptions[0].SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca") - c.Assert(resp.Subscriptions[0].Owner, Equals, "123456789012") - c.Assert(resp.Subscriptions[0].Endpoint, Equals, "example@amazon.com") - c.Assert(resp.Subscriptions[0].Protocol, Equals, "email") - c.Assert(err, IsNil) -} - -func (s *S) TestCreatePlatformApplication(c *C) { - testServer.Response(200, nil, TestCreatePlatformApplicationXmlOK) - - attrs := []sns.AttributeEntry{ - sns.AttributeEntry{Key: "PlatformCredential", Value: "AIzaSyClE2lcV2zEKTLYYo645zfk2jhQPFeyxDo"}, - sns.AttributeEntry{Key: "PlatformPrincipal", Value: "There is no principal for GCM"}, - } - opt := &sns.PlatformApplicationOpt{Name: "gcmpushapp", Platform: "GCM", Attributes: attrs} - resp, err := s.sns.CreatePlatformApplication(opt) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.PlatformApplicationArn, Equals, "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp") - c.Assert(resp.RequestId, Equals, "b6f0e78b-e9d4-5a0e-b973-adc04e8a4ff9") - - c.Assert(err, IsNil) -} - -func (s *S) TestCreatePlatformEndpoint(c *C) { - testServer.Response(200, nil, TestCreatePlatformEndpointXmlOK) - - opt := &sns.PlatformEndpointOpt{PlatformApplicationArn: "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp", - CustomUserData: "UserId=27576823", Token: "APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE"} - - resp, err := s.sns.CreatePlatformEndpoint(opt) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.EndpointArn, Equals, "arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3") - c.Assert(resp.RequestId, Equals, "6613341d-3e15-53f7-bf3c-7e56994ba278") - - c.Assert(err, IsNil) -} - -func (s *S) TestDeleteEndpoint(c *C) { - testServer.Response(200, nil, DeleteEndpointXmlOK) - - resp, err := s.sns.DeleteEndpoint("arn:aws:sns:us-west-2:123456789012:endpoint/GCM%/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.RequestId, Equals, "c1d2b191-353c-5a5f-8969-fbdd3900afa8") - - c.Assert(err, IsNil) -} - -func (s *S) TestDeletePlatformApplication(c *C) { - testServer.Response(200, nil, TestDeletePlatformApplicationXmlOK) - - resp, err := s.sns.DeletePlatformApplication("arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.RequestId, Equals, "097dac18-7a77-5823-a8dd-e65476dcb037") - - c.Assert(err, IsNil) -} - -func (s *S) TestGetEndpointAttributes(c *C) { - testServer.Response(200, nil, TestGetEndpointAttributesXmlOK) - - resp, err := s.sns.GetEndpointAttributes("arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(len(resp.Attributes), Equals, 3) - c.Assert(resp.Attributes[0].Key, Equals, "Enabled") - c.Assert(resp.Attributes[0].Value, Equals, "true") - - c.Assert(resp.Attributes[1].Key, Equals, "CustomUserData") - c.Assert(resp.Attributes[1].Value, Equals, "UserId=01234567") - - c.Assert(resp.Attributes[2].Key, Equals, "Token") - c.Assert(resp.Attributes[2].Value, Equals, "APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE") - - c.Assert(resp.RequestId, Equals, "6c725a19-a142-5b77-94f9-1055a9ea04e7") - - c.Assert(err, IsNil) -} - -func (s *S) TestGetPlatformApplicationAttributes(c *C) { - testServer.Response(200, nil, TestGetPlatformApplicationAttributesXmlOK) - - resp, err := s.sns.GetPlatformApplicationAttributes("arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp", "") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(len(resp.Attributes), Not(Equals), 0) - c.Assert(resp.Attributes[0].Key, Equals, "AllowEndpointPolicies") - c.Assert(resp.Attributes[0].Value, Equals, "false") - c.Assert(resp.RequestId, Equals, "74848df2-87f6-55ed-890c-c7be80442462") - - c.Assert(err, IsNil) -} - -func (s *S) TestListEndpointsByPlatformApplication(c *C) { - testServer.Response(200, nil, TestListEndpointsByPlatformApplicationXmlOK) - - resp, err := s.sns.ListEndpointsByPlatformApplication("arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp", "") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(len(resp.Endpoints), Not(Equals), 0) - c.Assert(resp.Endpoints[0].EndpointArn, Equals, "arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3") - c.Assert(len(resp.Endpoints[0].Attributes), Equals, 3) - c.Assert(resp.Endpoints[0].Attributes[0].Key, Equals, "Enabled") - c.Assert(resp.Endpoints[0].Attributes[0].Value, Equals, "true") - c.Assert(resp.Endpoints[0].Attributes[1].Key, Equals, "CustomUserData") - c.Assert(resp.Endpoints[0].Attributes[1].Value, Equals, "UserId=27576823") - c.Assert(resp.Endpoints[0].Attributes[2].Key, Equals, "Token") - c.Assert(resp.Endpoints[0].Attributes[2].Value, Equals, "APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE") - - c.Assert(resp.RequestId, Equals, "9a48768c-dac8-5a60-aec0-3cc27ea08d96") - - c.Assert(err, IsNil) -} - -func (s *S) TestListPlatformApplications(c *C) { - testServer.Response(200, nil, TestListPlatformApplicationsXmlOK) - - resp, err := s.sns.ListPlatformApplications("") - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(len(resp.PlatformApplications), Not(Equals), 0) - - c.Assert(resp.PlatformApplications[0].PlatformApplicationArn, Equals, "arn:aws:sns:us-west-2:123456789012:app/APNS_SANDBOX/apnspushapp") - c.Assert(len(resp.PlatformApplications[0].Attributes), Equals, 1) - c.Assert(resp.PlatformApplications[0].Attributes[0].Key, Equals, "AllowEndpointPolicies") - c.Assert(resp.PlatformApplications[0].Attributes[0].Value, Equals, "false") - - c.Assert(resp.PlatformApplications[1].PlatformApplicationArn, Equals, "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp") - c.Assert(len(resp.PlatformApplications[1].Attributes), Equals, 1) - c.Assert(resp.PlatformApplications[1].Attributes[0].Key, Equals, "AllowEndpointPolicies") - c.Assert(resp.PlatformApplications[1].Attributes[0].Value, Equals, "false") - - c.Assert(resp.RequestId, Equals, "315a335e-85d8-52df-9349-791283cbb529") - - c.Assert(err, IsNil) -} - -func (s *S) TestSetEndpointAttributes(c *C) { - testServer.Response(200, nil, TestSetEndpointAttributesXmlOK) - - attrs := []sns.AttributeEntry{ - sns.AttributeEntry{Key: "CustomUserData", Value: "My custom userdata"}, - } - - opts := &sns.SetEndpointAttributesOpt{ - EndpointArn: "arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3", - Attributes: attrs} - - resp, err := s.sns.SetEndpointAttributes(opts) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.RequestId, Equals, "2fe0bfc7-3e85-5ee5-a9e2-f58b35e85f6a") - - c.Assert(err, IsNil) -} - -func (s *S) TestSetPlatformApplicationAttributes(c *C) { - testServer.Response(200, nil, TestSetPlatformApplicationAttributesXmlOK) - - attrs := []sns.AttributeEntry{ - sns.AttributeEntry{Key: "EventEndpointCreated", Value: "arn:aws:sns:us-west-2:123456789012:topicarn"}, - } - - opts := &sns.SetPlatformApplicationAttributesOpt{ - PlatformApplicationArn: "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp", - Attributes: attrs} - - resp, err := s.sns.SetPlatformApplicationAttributes(opts) - req := testServer.WaitRequest() - - c.Assert(req.Method, Equals, "GET") - c.Assert(req.URL.Path, Equals, "/") - c.Assert(req.Header["Date"], Not(Equals), "") - - c.Assert(resp.RequestId, Equals, "cf577bcc-b3dc-5463-88f1-3180b9412395") - - c.Assert(err, IsNil) -} diff --git a/vendor/github.com/goamz/goamz/exp/sns/subscription.go b/vendor/github.com/goamz/goamz/exp/sns/subscription.go deleted file mode 100644 index cbfef8b2c..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/subscription.go +++ /dev/null @@ -1,165 +0,0 @@ -package sns - -type Subscription struct { - Endpoint string - Owner string - Protocol string - SubscriptionArn string - TopicArn string -} - -type ListSubscriptionsResp struct { - Subscriptions []Subscription `xml:"ListSubscriptionsResult>Subscriptions>member"` - NextToken string - ResponseMetadata -} - -type PublishOpt struct { - Message string - MessageStructure string - Subject string - TopicArn string - TargetArn string -} - -type PublishResp struct { - MessageId string `xml:"PublishResult>MessageId"` - ResponseMetadata -} - -type SubscribeResponse struct { - SubscriptionArn string `xml:"SubscribeResult>SubscriptionArn"` - ResponseMetadata -} - -type UnsubscribeResponse struct { - ResponseMetadata -} - -type ConfirmSubscriptionResponse struct { - SubscriptionArn string `xml:"ConfirmSubscriptionResult>SubscriptionArn"` - ResponseMetadata -} - -type ConfirmSubscriptionOpt struct { - AuthenticateOnUnsubscribe string - Token string - TopicArn string -} - -type ListSubscriptionByTopicResponse struct { - Subscriptions []Subscription `xml:"ListSubscriptionsByTopicResult>Subscriptions>member"` - ResponseMetadata -} - -type ListSubscriptionByTopicOpt struct { - NextToken string - TopicArn string -} - -// Publish -// -// See http://goo.gl/AY2D8 for more details. -func (sns *SNS) Publish(options *PublishOpt) (resp *PublishResp, err error) { - resp = &PublishResp{} - params := makeParams("Publish") - - if options.Subject != "" { - params["Subject"] = options.Subject - } - - if options.MessageStructure != "" { - params["MessageStructure"] = options.MessageStructure - } - - if options.Message != "" { - params["Message"] = options.Message - } - - if options.TopicArn != "" { - params["TopicArn"] = options.TopicArn - } - - if options.TargetArn != "" { - params["TargetArn"] = options.TargetArn - } - - err = sns.query(params, resp) - return -} - -// Subscribe -// -// See http://goo.gl/c3iGS for more details. -func (sns *SNS) Subscribe(Endpoint, Protocol, TopicArn string) (resp *SubscribeResponse, err error) { - resp = &SubscribeResponse{} - params := makeParams("Subscribe") - - params["Endpoint"] = Endpoint - params["Protocol"] = Protocol - params["TopicArn"] = TopicArn - - err = sns.query(params, resp) - return -} - -// Unsubscribe -// -// See http://goo.gl/4l5Ge for more details. -func (sns *SNS) Unsubscribe(SubscriptionArn string) (resp *UnsubscribeResponse, err error) { - resp = &UnsubscribeResponse{} - params := makeParams("Unsubscribe") - - params["SubscriptionArn"] = SubscriptionArn - - err = sns.query(params, resp) - return -} - -// ConfirmSubscription -// -// See http://goo.gl/3hXzH for more details. -func (sns *SNS) ConfirmSubscription(options *ConfirmSubscriptionOpt) (resp *ConfirmSubscriptionResponse, err error) { - resp = &ConfirmSubscriptionResponse{} - params := makeParams("ConfirmSubscription") - - if options.AuthenticateOnUnsubscribe != "" { - params["AuthenticateOnUnsubscribe"] = options.AuthenticateOnUnsubscribe - } - - params["Token"] = options.Token - params["TopicArn"] = options.TopicArn - - err = sns.query(params, resp) - return -} - -// ListSubscriptions -// -// See http://goo.gl/k3aGn for more details. -func (sns *SNS) ListSubscriptions(NextToken *string) (resp *ListSubscriptionsResp, err error) { - resp = &ListSubscriptionsResp{} - params := makeParams("ListSubscriptions") - if NextToken != nil { - params["NextToken"] = *NextToken - } - err = sns.query(params, resp) - return -} - -// ListSubscriptionByTopic -// -// See http://goo.gl/LaVcC for more details. -func (sns *SNS) ListSubscriptionByTopic(options *ListSubscriptionByTopicOpt) (resp *ListSubscriptionByTopicResponse, err error) { - resp = &ListSubscriptionByTopicResponse{} - params := makeParams("ListSbubscriptionByTopic") - - if options.NextToken != "" { - params["NextToken"] = options.NextToken - } - - params["TopicArn"] = options.TopicArn - - err = sns.query(params, resp) - return -} diff --git a/vendor/github.com/goamz/goamz/exp/sns/topic.go b/vendor/github.com/goamz/goamz/exp/sns/topic.go deleted file mode 100644 index 601325ec9..000000000 --- a/vendor/github.com/goamz/goamz/exp/sns/topic.go +++ /dev/null @@ -1,104 +0,0 @@ -package sns - -import ( - "errors" -) - -type Topic struct { - SNS *SNS - TopicArn string -} - -type ListTopicsResp struct { - Topics []Topic `xml:"ListTopicsResult>Topics>member"` - NextToken string - ResponseMetadata -} - -type CreateTopicResp struct { - Topic Topic `xml:"CreateTopicResult"` - ResponseMetadata -} - -type DeleteTopicResp struct { - ResponseMetadata -} - -type GetTopicAttributesResp struct { - Attributes []AttributeEntry `xml:"GetTopicAttributesResult>Attributes>entry"` - ResponseMetadata -} - -type SetTopicAttributesResponse struct { - ResponseMetadata -} - -// ListTopics -// -// See http://goo.gl/lfrMK for more details. -func (sns *SNS) ListTopics(NextToken *string) (resp *ListTopicsResp, err error) { - resp = &ListTopicsResp{} - params := makeParams("ListTopics") - if NextToken != nil { - params["NextToken"] = *NextToken - } - - err = sns.query(params, resp) - for i, _ := range resp.Topics { - resp.Topics[i].SNS = sns - } - return -} - -// CreateTopic -// -// See http://goo.gl/m9aAt for more details. -func (sns *SNS) CreateTopic(Name string) (resp *CreateTopicResp, err error) { - resp = &CreateTopicResp{} - params := makeParams("CreateTopic") - params["Name"] = Name - err = sns.query(params, resp) - resp.Topic.SNS = sns - return -} - -// Delete -// -// Helper function for deleting a topic -func (topic *Topic) Delete() (resp *DeleteTopicResp, err error) { - resp = &DeleteTopicResp{} - params := makeParams("DeleteTopic") - params["TopicArn"] = topic.TopicArn - err = topic.SNS.query(params, resp) - return -} - -// GetTopicAttributes -// -// See http://goo.gl/WXRoX for more details. -func (sns *SNS) GetTopicAttributes(TopicArn string) (resp *GetTopicAttributesResp, err error) { - resp = &GetTopicAttributesResp{} - params := makeParams("GetTopicAttributes") - params["TopicArn"] = TopicArn - err = sns.query(params, resp) - return -} - -// SetTopicAttributes -// -// See http://goo.gl/oVYW7 for more details. -func (sns *SNS) SetTopicAttributes(AttributeName, AttributeValue, TopicArn string) (resp *SetTopicAttributesResponse, err error) { - resp = &SetTopicAttributesResponse{} - params := makeParams("SetTopicAttributes") - - if AttributeName == "" || TopicArn == "" { - return nil, errors.New("Invalid Attribute Name or TopicArn") - } - - params["AttributeName"] = AttributeName - params["AttributeValue"] = AttributeValue - params["TopicArn"] = TopicArn - - err = sns.query(params, resp) - return -} |