From 9c8671687465cf6ff8f847ffc67353a1d60a8780 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Sun, 26 Oct 2014 16:54:51 +1100 Subject: [PATCH 01/33] Initial structure for ElasticBeanstalk Added EBEndpoint to aws.go Cloned lots of util functions from elb package implemented CreateApplication for eb --- aws/aws.go | 12 ++++ eb/eb.go | 149 +++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 49 ++++++++++++++ eb/responses_test.go | 22 +++++++ eb/sign.go | 38 +++++++++++ 5 files changed, 270 insertions(+) create mode 100644 eb/eb.go create mode 100644 eb/eb_test.go create mode 100644 eb/responses_test.go create mode 100644 eb/sign.go diff --git a/aws/aws.go b/aws/aws.go index cfc42c03..5cfeaa24 100644 --- a/aws/aws.go +++ b/aws/aws.go @@ -33,6 +33,7 @@ type Region struct { SNSEndpoint string SQSEndpoint string IAMEndpoint string + EBEndpoint string ELBEndpoint string AutoScalingEndpoint string RdsEndpoint string @@ -50,6 +51,7 @@ var USGovWest = Region{ "https://sns.us-gov-west-1.amazonaws.com", "https://sqs.us-gov-west-1.amazonaws.com", "https://iam.us-gov.amazonaws.com", + "", "https://elasticloadbalancing.us-gov-west-1.amazonaws.com", "https://autoscaling.us-gov-west-1.amazonaws.com", "https://rds.us-gov-west-1.amazonaws.com", @@ -67,6 +69,7 @@ var USEast = Region{ "https://sns.us-east-1.amazonaws.com", "https://sqs.us-east-1.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.us-east-1.amazonaws.com", "https://elasticloadbalancing.us-east-1.amazonaws.com", "https://autoscaling.us-east-1.amazonaws.com", "https://rds.us-east-1.amazonaws.com", @@ -84,6 +87,7 @@ var USWest = Region{ "https://sns.us-west-1.amazonaws.com", "https://sqs.us-west-1.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.us-west-1.amazonaws.com", "https://elasticloadbalancing.us-west-1.amazonaws.com", "https://autoscaling.us-west-1.amazonaws.com", "https://rds.us-west-1.amazonaws.com", @@ -101,6 +105,7 @@ var USWest2 = Region{ "https://sns.us-west-2.amazonaws.com", "https://sqs.us-west-2.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.us-west-2.amazonaws.com", "https://elasticloadbalancing.us-west-2.amazonaws.com", "https://autoscaling.us-west-2.amazonaws.com", "https://rds.us-west-2.amazonaws.com", @@ -118,6 +123,7 @@ var EUWest = Region{ "https://sns.eu-west-1.amazonaws.com", "https://sqs.eu-west-1.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.eu-west-1.amazonaws.com", "https://elasticloadbalancing.eu-west-1.amazonaws.com", "https://autoscaling.eu-west-1.amazonaws.com", "https://rds.eu-west-1.amazonaws.com", @@ -135,6 +141,7 @@ var EUCentral = Region{ "https://sns.eu-central-1.amazonaws.com", "https://sqs.eu-central-1.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.eu-central-1.amazonaws.com", "https://elasticloadbalancing.eu-central-1.amazonaws.com", "https://autoscaling.eu-central-1.amazonaws.com", "https://rds.eu-central-1.amazonaws.com", @@ -152,6 +159,7 @@ var APSoutheast = Region{ "https://sns.ap-southeast-1.amazonaws.com", "https://sqs.ap-southeast-1.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.ap-southeast-1.amazonaws.com", "https://elasticloadbalancing.ap-southeast-1.amazonaws.com", "https://autoscaling.ap-southeast-1.amazonaws.com", "https://rds.ap-southeast-1.amazonaws.com", @@ -169,6 +177,7 @@ var APSoutheast2 = Region{ "https://sns.ap-southeast-2.amazonaws.com", "https://sqs.ap-southeast-2.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.ap-southeast-2.amazonaws.com", "https://elasticloadbalancing.ap-southeast-2.amazonaws.com", "https://autoscaling.ap-southeast-2.amazonaws.com", "https://rds.ap-southeast-2.amazonaws.com", @@ -186,6 +195,7 @@ var APNortheast = Region{ "https://sns.ap-northeast-1.amazonaws.com", "https://sqs.ap-northeast-1.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.ap-northeast-1.amazonaws.com", "https://elasticloadbalancing.ap-northeast-1.amazonaws.com", "https://autoscaling.ap-northeast-1.amazonaws.com", "https://rds.ap-northeast-1.amazonaws.com", @@ -203,6 +213,7 @@ var SAEast = Region{ "https://sns.sa-east-1.amazonaws.com", "https://sqs.sa-east-1.amazonaws.com", "https://iam.amazonaws.com", + "elasticbeanstalk.sa-east-1.amazonaws.com", "https://elasticloadbalancing.sa-east-1.amazonaws.com", "https://autoscaling.sa-east-1.amazonaws.com", "https://rds.sa-east-1.amazonaws.com", @@ -220,6 +231,7 @@ var CNNorth = Region{ "https://sns.cn-north-1.amazonaws.com.cn", "https://sqs.cn-north-1.amazonaws.com.cn", "https://iam.cn-north-1.amazonaws.com.cn", + "", "https://elasticloadbalancing.cn-north-1.amazonaws.com.cn", "https://autoscaling.cn-north-1.amazonaws.com.cn", "https://rds.cn-north-1.amazonaws.com.cn", diff --git a/eb/eb.go b/eb/eb.go new file mode 100644 index 00000000..c8e342c2 --- /dev/null +++ b/eb/eb.go @@ -0,0 +1,149 @@ +// The eb package provides types and functions for interaction with the AWS +// Elastic Beanstalk service (EB) +package eb + +import ( + "encoding/xml" + "github.com/mitchellh/goamz/aws" + "net/http" + "net/url" + "strconv" + "time" +) + +type EB struct { + aws.Auth + aws.Region + httpClient *http.Client +} + +const APIVersion = "2010-12-01" + +func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *EB { + return &EB{auth, region, httpClient} +} + +func (eb *EB) query(params map[string]string, resp interface{}) error { + params["Version"] = APIVersion + params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339) + + endpoint, err := url.Parse(eb.Region.EBEndpoint) + if err != nil { + return err + } + + sign(eb.Auth, "GET", "/", params, endpoint.Host) + endpoint.RawQuery = multimap(params).Encode() + r, err := eb.httpClient.Get(endpoint.String()) + + if err != nil { + return err + } + defer r.Body.Close() + if r.StatusCode > 200 { + return buildError(r) + } + + decoder := xml.NewDecoder(r.Body) + decodedBody := decoder.Decode(resp) + + return decodedBody +} + +func buildError(r *http.Response) error { + var ( + err Error + errors xmlErrors + ) + xml.NewDecoder(r.Body).Decode(&errors) + if len(errors.Errors) > 0 { + err = errors.Errors[0] + } + 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 +} + +func makeParams(action string) map[string]string { + params := make(map[string]string) + params["Action"] = action + return params +} + +// ---------------------------------------------------------------------------- +// Create + +// The CreateApplication request parameters +type CreateApplication struct { + ApplicationName string + Description string +} + +type CreateApplicationResp struct { + ApplicationName string `xml:"CreateApplicationResult>Application>ApplicationName"` + ConfigurationTemplates []string `xml:"CreateApplicationResult>Application>ConfigurationTemplates>member"` + DateCreated string `xml:"CreateApplicationResult>Application>DateCreated"` + DateUpdated string `xml:"CreateApplicationResult>Application>DateUpdated"` + Description string `xml:"CreateApplicationResult>Application>Description"` + Versions []string `xml:"CreateApplicationResult>Application>Versions>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateApplication(options *CreateApplication) (resp *CreateApplicationResp, err error) { + params := makeParams("CreateApplication") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + resp = &CreateApplicationResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// Responses + +type SimpleResp struct { + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +type xmlErrors struct { + Errors []Error `xml:"Error"` +} + +// Error encapsulates an elb error. +type Error struct { + // HTTP status code of the error. + StatusCode int + + // AWS code of the error. + Code string + + // Message explaining the error. + Message string +} + +func (e *Error) Error() string { + var prefix string + if e.Code != "" { + prefix = e.Code + ": " + } + if prefix == "" && e.StatusCode > 0 { + prefix = strconv.Itoa(e.StatusCode) + ": " + } + return prefix + e.Message +} diff --git a/eb/eb_test.go b/eb/eb_test.go new file mode 100644 index 00000000..63da5b57 --- /dev/null +++ b/eb/eb_test.go @@ -0,0 +1,49 @@ +package eb_test + +import ( + "github.com/mitchellh/goamz/aws" + "github.com/mitchellh/goamz/eb" + "github.com/mitchellh/goamz/testutil" + . "github.com/motain/gocheck" + "testing" +) + +func Test(t *testing.T) { + TestingT(t) +} + +type S struct { + eb *eb.EB +} + +var _ = Suite(&S{}) + +var testServer = testutil.NewHTTPServer() + +func (s *S) SetUpSuite(c *C) { + testServer.Start() + auth := aws.Auth{"abc", "123", ""} + s.eb = eb.NewWithClient(auth, aws.Region{EBEndpoint: testServer.URL}, testutil.DefaultClient) +} + +func (s *S) TearDownTest(c *C) { + testServer.Flush() +} + +func (s *S) TestCreateApplication(c *C) { + testServer.Response(200, nil, CreateApplicationExample) + + options := eb.CreateApplication{ + ApplicationName: "SampleApp", + Description: "Sample Description", + } + + resp, err := s.eb.CreateApplication(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateApplication"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"Sample Description"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "8b00e053-f1d6-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go new file mode 100644 index 00000000..926722e3 --- /dev/null +++ b/eb/responses_test.go @@ -0,0 +1,22 @@ +package eb_test + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplication.html +var CreateApplicationExample = ` + + + + + Sample Description + SampleApp + 2010-11-16T23:09:20.256Z + 2010-11-16T23:09:20.256Z + + Default + + + + + 8b00e053-f1d6-11df-8a78-9f77047e0d0c + + +` diff --git a/eb/sign.go b/eb/sign.go new file mode 100644 index 00000000..eea0a78b --- /dev/null +++ b/eb/sign.go @@ -0,0 +1,38 @@ +package eb + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/base64" + "github.com/mitchellh/goamz/aws" + "sort" + "strings" +) + +// ---------------------------------------------------------------------------- +// Version 2 signing (http://goo.gl/RSRp5) + +var b64 = base64.StdEncoding + +func sign(auth aws.Auth, method, path string, params map[string]string, host string) { + params["AWSAccessKeyId"] = auth.AccessKey + params["SignatureVersion"] = "2" + params["SignatureMethod"] = "HmacSHA256" + if auth.Token != "" { + params["SecurityToken"] = auth.Token + } + + 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) +} From c95937965d048405c0550fa4df094c918da0b768 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Sun, 26 Oct 2014 17:32:21 +1100 Subject: [PATCH 02/33] Adding protocol to EB Endpoint URL --- aws/aws.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/aws/aws.go b/aws/aws.go index 5cfeaa24..a6832a0f 100644 --- a/aws/aws.go +++ b/aws/aws.go @@ -69,7 +69,7 @@ var USEast = Region{ "https://sns.us-east-1.amazonaws.com", "https://sqs.us-east-1.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.us-east-1.amazonaws.com", + "https://elasticbeanstalk.us-east-1.amazonaws.com", "https://elasticloadbalancing.us-east-1.amazonaws.com", "https://autoscaling.us-east-1.amazonaws.com", "https://rds.us-east-1.amazonaws.com", @@ -87,7 +87,7 @@ var USWest = Region{ "https://sns.us-west-1.amazonaws.com", "https://sqs.us-west-1.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.us-west-1.amazonaws.com", + "https://elasticbeanstalk.us-west-1.amazonaws.com", "https://elasticloadbalancing.us-west-1.amazonaws.com", "https://autoscaling.us-west-1.amazonaws.com", "https://rds.us-west-1.amazonaws.com", @@ -105,7 +105,7 @@ var USWest2 = Region{ "https://sns.us-west-2.amazonaws.com", "https://sqs.us-west-2.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.us-west-2.amazonaws.com", + "https://elasticbeanstalk.us-west-2.amazonaws.com", "https://elasticloadbalancing.us-west-2.amazonaws.com", "https://autoscaling.us-west-2.amazonaws.com", "https://rds.us-west-2.amazonaws.com", @@ -123,7 +123,7 @@ var EUWest = Region{ "https://sns.eu-west-1.amazonaws.com", "https://sqs.eu-west-1.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.eu-west-1.amazonaws.com", + "https://elasticbeanstalk.eu-west-1.amazonaws.com", "https://elasticloadbalancing.eu-west-1.amazonaws.com", "https://autoscaling.eu-west-1.amazonaws.com", "https://rds.eu-west-1.amazonaws.com", @@ -141,7 +141,7 @@ var EUCentral = Region{ "https://sns.eu-central-1.amazonaws.com", "https://sqs.eu-central-1.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.eu-central-1.amazonaws.com", + "https://elasticbeanstalk.eu-central-1.amazonaws.com", "https://elasticloadbalancing.eu-central-1.amazonaws.com", "https://autoscaling.eu-central-1.amazonaws.com", "https://rds.eu-central-1.amazonaws.com", @@ -159,7 +159,7 @@ var APSoutheast = Region{ "https://sns.ap-southeast-1.amazonaws.com", "https://sqs.ap-southeast-1.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.ap-southeast-1.amazonaws.com", + "https://elasticbeanstalk.ap-southeast-1.amazonaws.com", "https://elasticloadbalancing.ap-southeast-1.amazonaws.com", "https://autoscaling.ap-southeast-1.amazonaws.com", "https://rds.ap-southeast-1.amazonaws.com", @@ -177,7 +177,7 @@ var APSoutheast2 = Region{ "https://sns.ap-southeast-2.amazonaws.com", "https://sqs.ap-southeast-2.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.ap-southeast-2.amazonaws.com", + "https://elasticbeanstalk.ap-southeast-2.amazonaws.com", "https://elasticloadbalancing.ap-southeast-2.amazonaws.com", "https://autoscaling.ap-southeast-2.amazonaws.com", "https://rds.ap-southeast-2.amazonaws.com", @@ -195,7 +195,7 @@ var APNortheast = Region{ "https://sns.ap-northeast-1.amazonaws.com", "https://sqs.ap-northeast-1.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.ap-northeast-1.amazonaws.com", + "https://elasticbeanstalk.ap-northeast-1.amazonaws.com", "https://elasticloadbalancing.ap-northeast-1.amazonaws.com", "https://autoscaling.ap-northeast-1.amazonaws.com", "https://rds.ap-northeast-1.amazonaws.com", @@ -213,7 +213,7 @@ var SAEast = Region{ "https://sns.sa-east-1.amazonaws.com", "https://sqs.sa-east-1.amazonaws.com", "https://iam.amazonaws.com", - "elasticbeanstalk.sa-east-1.amazonaws.com", + "https://elasticbeanstalk.sa-east-1.amazonaws.com", "https://elasticloadbalancing.sa-east-1.amazonaws.com", "https://autoscaling.sa-east-1.amazonaws.com", "https://rds.sa-east-1.amazonaws.com", From 8cde83b263b8205edb3fafbde2ffb4631bc5c02c Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Sun, 26 Oct 2014 17:32:33 +1100 Subject: [PATCH 03/33] Added DeleteApplication function --- eb/eb.go | 34 ++++++++++++++++++++++++++++++++++ eb/eb_test.go | 16 ++++++++++++++++ eb/responses_test.go | 8 ++++++++ 3 files changed, 58 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index c8e342c2..0e54b96a 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -19,6 +19,11 @@ type EB struct { const APIVersion = "2010-12-01" +// New creates a new ELB instance. +func New(auth aws.Auth, region aws.Region) *EB { + return NewWithClient(auth, region, aws.RetryingClient) +} + func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *EB { return &EB{auth, region, httpClient} } @@ -115,6 +120,35 @@ func (eb *EB) CreateApplication(options *CreateApplication) (resp *CreateApplica return } +// ---------------------------------------------------------------------------- +// Delete + +// The DeleteApplication request parameters +type DeleteApplication struct { + ApplicationName string + TerminateEnvByForce bool +} + +func (eb *EB) DeleteApplication(options *DeleteApplication) (resp *SimpleResp, err error) { + params := makeParams("DeleteApplication") + + params["ApplicationName"] = options.ApplicationName + + if options.TerminateEnvByForce { + params["TerminateEnvByForce"] = "true" + } + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index 63da5b57..5fe73f62 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -47,3 +47,19 @@ func (s *S) TestCreateApplication(c *C) { c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "8b00e053-f1d6-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDeleteLoadBalancer(c *C) { + testServer.Response(200, nil, DeleteApplicationExample) + + options := eb.DeleteApplication{ + ApplicationName: "foobar", + } + + resp, err := s.eb.DeleteApplication(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteApplication"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"foobar"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "1f155abd-f1d7-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 926722e3..0ae439d8 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -20,3 +20,11 @@ var CreateApplicationExample = ` ` + +var DeleteApplicationExample = ` + + + 1f155abd-f1d7-11df-8a78-9f77047e0d0c + + +` From 29a84ab55ed0307487cb8e6812805cce458bd88f Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Sun, 26 Oct 2014 23:05:21 +1100 Subject: [PATCH 04/33] Improving the CreateApplication tests --- eb/eb_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eb/eb_test.go b/eb/eb_test.go index 5fe73f62..18298e49 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -45,6 +45,11 @@ func (s *S) TestCreateApplication(c *C) { c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) c.Assert(req.Form["Description"], DeepEquals, []string{"Sample Description"}) c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.ConfigurationTemplates, DeepEquals, []string{"Default"}) + c.Assert(resp.DateCreated, Equals, "2010-11-16T23:09:20.256Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-16T23:09:20.256Z") + c.Assert(resp.Description, Equals, "Sample Description") c.Assert(resp.RequestId, Equals, "8b00e053-f1d6-11df-8a78-9f77047e0d0c") } From 9fb59ee0ca55e0352d7f5889638e5b60f2ea86c9 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Sun, 26 Oct 2014 23:05:50 +1100 Subject: [PATCH 05/33] Adding CheckDNSAvailability method --- eb/eb.go | 28 ++++++++++++++++++++++++++++ eb/eb_test.go | 18 ++++++++++++++++++ eb/responses_test.go | 11 +++++++++++ 3 files changed, 57 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 0e54b96a..83b42d3e 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -120,6 +120,34 @@ func (eb *EB) CreateApplication(options *CreateApplication) (resp *CreateApplica return } +// ---------------------------------------------------------------------------- +// CheckDNSAvailability + +type CheckDNSAvailability struct { + CNAMEPrefix string +} + +type CheckDNSAvailabilityResp struct { + FullyQualifiedCNAME string `xml:"CheckDNSAvailabilityResult>FullyQualifiedCNAME"` + Available bool `xml:"CheckDNSAvailabilityResult>Available"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CheckDNSAvailability(options *CheckDNSAvailability) (resp *CheckDNSAvailabilityResp, err error) { + params := makeParams("CheckDNSAvailability") + + params["CNAMEPrefix"] = options.CNAMEPrefix + resp = &CheckDNSAvailabilityResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Delete diff --git a/eb/eb_test.go b/eb/eb_test.go index 18298e49..2abd1d13 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -68,3 +68,21 @@ func (s *S) TestDeleteLoadBalancer(c *C) { c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "1f155abd-f1d7-11df-8a78-9f77047e0d0c") } + +func (s *S) TestCheckDNSAvailability(c *C) { + testServer.Response(200, nil, CheckDNSAvailabilityExample) + + options := eb.CheckDNSAvailability{ + CNAMEPrefix: "sampleapplication", + } + + resp, err := s.eb.CheckDNSAvailability(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CheckDNSAvailability"}) + c.Assert(req.Form["CNAMEPrefix"], DeepEquals, []string{"sampleapplication"}) + c.Assert(err, IsNil) + c.Assert(resp.FullyQualifiedCNAME, Equals, "sampleapplication.elasticbeanstalk.amazonaws.com") + c.Assert(resp.Available, Equals, true) + c.Assert(resp.RequestId, Equals, "12f6701f-f1d6-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 0ae439d8..8cbd8b14 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -28,3 +28,14 @@ var DeleteApplicationExample = ` ` +var CheckDNSAvailabilityExample = ` + + + sampleapplication.elasticbeanstalk.amazonaws.com + true + + + 12f6701f-f1d6-11df-8a78-9f77047e0d0c + + +` From fff5febf1612852b52be17ce02efe0c7785c3328 Mon Sep 17 00:00:00 2001 From: sebastian cole Date: Mon, 27 Oct 2014 15:05:01 +1100 Subject: [PATCH 06/33] Added CreateApplicationVersion method --- eb/eb.go | 50 ++++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 35 +++++++++++++++++++++++++++++++ eb/responses_test.go | 47 +++++++++++++++++++++++++++++++---------- 3 files changed, 121 insertions(+), 11 deletions(-) diff --git a/eb/eb.go b/eb/eb.go index 83b42d3e..019b9f59 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -120,6 +120,56 @@ func (eb *EB) CreateApplication(options *CreateApplication) (resp *CreateApplica return } +// ---------------------------------------------------------------------------- +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplicationVersion.html + +type S3Location struct { + S3Bucket string + S3Key string +} + +// The CreateApplicationVersion request parameters +type CreateApplicationVersion struct { + ApplicationName string + AutoCreateApplication bool + Description string + SourceBundle S3Location + VersionLabel string +} + +type CreateApplicationVersionResp struct { + ApplicationName string `xml:"CreateApplicationVersionResult>ApplicationVersion>ApplicationName"` + DateCreated string `xml:"CreateApplicationVersionResult>ApplicationVersion>DateCreated"` + DateUpdated string `xml:"CreateApplicationVersionResult>ApplicationVersion>DateUpdated"` + Description string `xml:"CreateApplicationVersionResult>ApplicationVersion>Description"` + SourceBundle S3Location `xml:"CreateApplicationVersionResult>ApplicationVersion>SourceBundle"` + VersionLabel string `xml:"CreateApplicationVersionResult>ApplicationVersion>VersionLabel"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateApplicationVersion(options *CreateApplicationVersion) (resp *CreateApplicationVersionResp, err error) { + params := makeParams("CreateApplicationVersion") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + if options.AutoCreateApplication { + params["AutoCreateApplication"] = "true" + } + params["SourceBundle.S3Bucket"] = options.SourceBundle.S3Bucket + params["SourceBundle.S3Key"] = options.SourceBundle.S3Key + params["VersionLabel"] = options.VersionLabel + + resp = &CreateApplicationVersionResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // CheckDNSAvailability diff --git a/eb/eb_test.go b/eb/eb_test.go index 2abd1d13..202fb96d 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -86,3 +86,38 @@ func (s *S) TestCheckDNSAvailability(c *C) { c.Assert(resp.Available, Equals, true) c.Assert(resp.RequestId, Equals, "12f6701f-f1d6-11df-8a78-9f77047e0d0c") } + +func (s *S) TestCreateApplicationVersion(c *C) { + testServer.Response(200, nil, CreateApplicationVersionExample) + + options := eb.CreateApplicationVersion{ + ApplicationName: "SampleApp", + VersionLabel: "Version1", + Description: "description", + AutoCreateApplication: true, + SourceBundle: eb.S3Location{ + S3Bucket: "amazonaws.com", + S3Key: "sample.war", + }, + } + + resp, err := s.eb.CreateApplicationVersion(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateApplicationVersion"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["VersionLabel"], DeepEquals, []string{"Version1"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"description"}) + c.Assert(req.Form["AutoCreateApplication"], DeepEquals, []string{"true"}) + c.Assert(req.Form["SourceBundle.S3Bucket"], DeepEquals, []string{"amazonaws.com"}) + c.Assert(req.Form["SourceBundle.S3Key"], DeepEquals, []string{"sample.war"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.DateCreated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.Description, Equals, "description") + c.Assert(resp.SourceBundle.S3Bucket, Equals, "amazonaws.com") + c.Assert(resp.SourceBundle.S3Key, Equals, "sample.war") + c.Assert(resp.VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "d653efef-f1f9-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 8cbd8b14..b4ae7d3b 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1,5 +1,18 @@ package eb_test +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CheckDNSAvailability.html +var CheckDNSAvailabilityExample = ` + + + sampleapplication.elasticbeanstalk.amazonaws.com + true + + + 12f6701f-f1d6-11df-8a78-9f77047e0d0c + + +` + // http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplication.html var CreateApplicationExample = ` @@ -21,6 +34,29 @@ var CreateApplicationExample = ` ` +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplicationVersion.html +var CreateApplicationVersionExample = ` + + + + + amazonaws.com + sample.war + + Version1 + description + SampleApp + 2010-11-17T03:21:59.161Z + 2010-11-17T03:21:59.161Z + + + + d653efef-f1f9-11df-8a78-9f77047e0d0c + + +` + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DeleteApplication.html var DeleteApplicationExample = ` @@ -28,14 +64,3 @@ var DeleteApplicationExample = ` ` -var CheckDNSAvailabilityExample = ` - - - sampleapplication.elasticbeanstalk.amazonaws.com - true - - - 12f6701f-f1d6-11df-8a78-9f77047e0d0c - - -` From ba0c6cce8d2455ec4c7e78e6b7fd4bd47d5e751f Mon Sep 17 00:00:00 2001 From: sebastian cole Date: Mon, 27 Oct 2014 15:58:06 +1100 Subject: [PATCH 07/33] Added CreateConfigurationTemplate method --- eb/eb.go | 65 ++++++++++++ eb/eb_test.go | 34 ++++++ eb/responses_test.go | 248 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 347 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 019b9f59..beb21e6f 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -170,6 +170,71 @@ func (eb *EB) CreateApplicationVersion(options *CreateApplicationVersion) (resp return } +// CreateConfigurationTemplate + +type ConfigurationOptionSetting struct { + Namespace string + OptionName string + Value string +} + +type SourceConfiguration struct { + ApplicationName string + TemplateName string +} + +type CreateConfigurationTemplate struct { + ApplicationName string + Description string + EnvironmentId string + OptionSettings []ConfigurationOptionSetting + SolutionStackName string + SourceConfiguration SourceConfiguration + TemplateName string +} + +type CreateConfigurationTemplateResp struct { + ApplicationName string `xml:"CreateConfigurationTemplateResult>ApplicationName"` + DateCreated string `xml:"CreateConfigurationTemplateResult>DateCreated"` + DateUpdated string `xml:"CreateConfigurationTemplateResult>DateUpdated"` + DeploymentStatus string `xml:"CreateConfigurationTemplateResult>DeploymentStatus"` + Description string `xml:"CreateConfigurationTemplateResult>Description"` + EnvironmentName string `xml:"CreateConfigurationTemplateResult>EnvironmentName"` + OptionSettings []ConfigurationOptionSetting `xml:"CreateConfigurationTemplateResult>OptionSettings>member"` + SolutionStackName string `xml:"CreateConfigurationTemplateResult>SolutionStackName"` + TemplateName string `xml:"CreateConfigurationTemplateResult>TemplateName"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateConfigurationTemplate(options *CreateConfigurationTemplate) (resp *CreateConfigurationTemplateResp, err error) { + params := makeParams("CreateConfigurationTemplate") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + params["EnvironmentId"] = options.EnvironmentId + + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+"Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+"OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+"Value"] = v.Value + } + + params["SolutionStackName"] = options.SolutionStackName + params["SourceConfiguration.ApplicationName"] = options.SourceConfiguration.ApplicationName + params["SourceConfiguration.TemplateName"] = options.SourceConfiguration.TemplateName + params["TemplateName"] = options.TemplateName + + resp = &CreateConfigurationTemplateResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // CheckDNSAvailability diff --git a/eb/eb_test.go b/eb/eb_test.go index 202fb96d..a38393b9 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -121,3 +121,37 @@ func (s *S) TestCreateApplicationVersion(c *C) { c.Assert(resp.VersionLabel, Equals, "Version1") c.Assert(resp.RequestId, Equals, "d653efef-f1f9-11df-8a78-9f77047e0d0c") } + +func (s *S) TestCreateConfigurationTemplate(c *C) { + testServer.Response(200, nil, CreateConfigurationTemplateExample) + + options := eb.CreateConfigurationTemplate{ + ApplicationName: "SampleApp", + Description: "ConfigTemplateDescription", + EnvironmentId: "", + OptionSettings: []eb.ConfigurationOptionSetting{}, + SolutionStackName: "32bit Amazon Linux running Tomcat 7", + SourceConfiguration: eb.SourceConfiguration{}, + TemplateName: "AppTemplate", + } + + resp, err := s.eb.CreateConfigurationTemplate(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateConfigurationTemplate"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"ConfigTemplateDescription"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{""}) + c.Assert(req.Form["SolutionStackName"], DeepEquals, []string{"32bit Amazon Linux running Tomcat 7"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"AppTemplate"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.DateCreated, Equals, "2010-11-17T03:48:19.640Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T03:48:19.640Z") + c.Assert(resp.Description, Equals, "ConfigTemplateDescription") + c.Assert(resp.OptionSettings[0].OptionName, Equals, "ImageId") + c.Assert(resp.OptionSettings[0].Value, Equals, "ami-f2f0069b") + c.Assert(resp.OptionSettings[0].Namespace, Equals, "aws:autoscaling:launchconfiguration") + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.RequestId, Equals, "846cd905-f1fd-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index b4ae7d3b..3c04d0b6 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -56,6 +56,254 @@ var CreateApplicationVersionExample = ` ` +var CreateConfigurationTemplateExample = ` + + + 32bit Amazon Linux running Tomcat 7 + + + ImageId + ami-f2f0069b + aws:autoscaling:launchconfiguration + + + Notification Endpoint + + aws:elasticbeanstalk:sns:topics + + + PARAM4 + + aws:elasticbeanstalk:application:environment + + + JDBC_CONNECTION_STRING + + aws:elasticbeanstalk:application:environment + + + SecurityGroups + elasticbeanstalk-default + aws:autoscaling:launchconfiguration + + + UnhealthyThreshold + 5 + aws:elb:healthcheck + + + InstanceType + t1.micro + aws:autoscaling:launchconfiguration + + + Statistic + Average + aws:autoscaling:trigger + + + LoadBalancerHTTPSPort + OFF + aws:elb:loadbalancer + + + Stickiness Cookie Expiration + 0 + aws:elb:policies + + + PARAM5 + + aws:elasticbeanstalk:application:environment + + + MeasureName + NetworkOut + aws:autoscaling:trigger + + + Interval + 30 + aws:elb:healthcheck + + + Application Healthcheck URL + / + aws:elasticbeanstalk:application + + + Notification Topic ARN + + aws:elasticbeanstalk:sns:topics + + + LowerBreachScaleIncrement + -1 + aws:autoscaling:trigger + + + XX:MaxPermSize + 64m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + UpperBreachScaleIncrement + 1 + aws:autoscaling:trigger + + + MinSize + 1 + aws:autoscaling:asg + + + Custom Availability Zones + us-east-1a + aws:autoscaling:asg + + + Availability Zones + Any 1 + aws:autoscaling:asg + + + LogPublicationControl + false + aws:elasticbeanstalk:hostmanager + + + JVM Options + + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + Notification Topic Name + + aws:elasticbeanstalk:sns:topics + + + PARAM2 + + aws:elasticbeanstalk:application:environment + + + LoadBalancerHTTPPort + 80 + aws:elb:loadbalancer + + + Timeout + 5 + aws:elb:healthcheck + + + BreachDuration + 2 + aws:autoscaling:trigger + + + MonitoringInterval + 5 minute + aws:autoscaling:launchconfiguration + + + PARAM1 + + aws:elasticbeanstalk:application:environment + + + MaxSize + 4 + aws:autoscaling:asg + + + LowerThreshold + 2000000 + aws:autoscaling:trigger + + + AWS_SECRET_KEY + + aws:elasticbeanstalk:application:environment + + + AWS_ACCESS_KEY_ID + + aws:elasticbeanstalk:application:environment + + + UpperThreshold + 6000000 + aws:autoscaling:trigger + + + Notification Protocol + email + aws:elasticbeanstalk:sns:topics + + + Unit + Bytes + aws:autoscaling:trigger + + + Xmx + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + Cooldown + 360 + aws:autoscaling:asg + + + Period + 1 + aws:autoscaling:trigger + + + Xms + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + EC2KeyName + + aws:autoscaling:launchconfiguration + + + Stickiness Policy + false + aws:elb:policies + + + PARAM3 + + aws:elasticbeanstalk:application:environment + + + HealthyThreshold + 3 + aws:elb:healthcheck + + + SSLCertificateId + + aws:elb:loadbalancer + + + ConfigTemplateDescription + SampleApp + 2010-11-17T03:48:19.640Z + AppTemplate + 2010-11-17T03:48:19.640Z + + + 846cd905-f1fd-11df-8a78-9f77047e0d0c + + +` + // http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DeleteApplication.html var DeleteApplicationExample = ` From 89c23e961ac887dbff79b15aac91a17264f4a7ad Mon Sep 17 00:00:00 2001 From: sebastian cole Date: Mon, 27 Oct 2014 16:51:41 +1100 Subject: [PATCH 08/33] Added CreateEnvironment method --- eb/eb.go | 109 +++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 32 +++++++++++++ eb/responses_test.go | 21 +++++++++ 3 files changed, 162 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index beb21e6f..3f670609 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -235,6 +235,115 @@ func (eb *EB) CreateConfigurationTemplate(options *CreateConfigurationTemplate) return } +// CreateEnvironment +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateEnvironment.html + +type OptionSpecification struct { + Namespace string + OptionName string +} + +type Tag struct { + Key string `xml:"Key"` + Value string `xml:"Value"` +} + +type EnvironmentTier struct { + Name string + Type string + Version string +} +type Listener struct { + Port int + Protocol string +} +type LoadBalancerDescription struct { + Domain string + Listeners []Listener + LoadBalancerName string +} + +type EnvironmentResourcesDescription struct { + LoadBalancer LoadBalancerDescription +} + +type CreateEnvironment struct { + ApplicationName string + CNAMEPrefix string + Description string + EnvironmentName string + OptionSettings []ConfigurationOptionSetting + OptionsToRemove []OptionSpecification + SolutionStackName string + Tags []Tag + TemplateName string + Tier EnvironmentTier + VersionLabel string +} + +type CreateEnvironmentResp struct { + ApplicationName string `xml:"CreateEnvironmentResult>ApplicationName"` + CNAME string `xml:"CreateEnvironmentResult>CNAME"` + DateCreated string `xml:"CreateEnvironmentResult>DateCreated"` + DateUpdated string `xml:"CreateEnvironmentResult>DateUpdated"` + Description string `xml:"CreateEnvironmentResult>Description"` + EndpointURL string `xml:"CreateEnvironmentResult>EndpointURL"` + EnvironmentId string `xml:"CreateEnvironmentResult>EnvironmentId"` + EnvironmentName string `xml:"CreateEnvironmentResult>EnvironmentName"` + Health string `xml:"CreateEnvironmentResult>Health"` + Resources EnvironmentResourcesDescription `xml:"CreateEnvironmentResult>Resources"` + SolutionStackName string `xml:"CreateEnvironmentResult>SolutionStackName"` + Status string `xml:"CreateEnvironmentResult>Status"` + TemplateName string `xml:"CreateEnvironmentResult>TemplateName"` + Tier EnvironmentTier `xml:"CreateEnvironmentResult>Tier"` + VersionLabel string `xml:"CreateEnvironmentResult>VersionLabel"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateEnvironment(options *CreateEnvironment) (resp *CreateEnvironmentResp, err error) { + params := makeParams("CreateEnvironment") + + params["ApplicationName"] = options.ApplicationName + params["CNAMEPrefix"] = options.CNAMEPrefix + params["Description"] = options.Description + params["EnvironmentName"] = options.EnvironmentName + + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+"Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+"OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+"Value"] = v.Value + } + + for i, v := range options.OptionsToRemove { + params["OptionsToRemove.member."+strconv.Itoa(i+1)+"Namespace"] = v.Namespace + params["OptionsToRemove.member."+strconv.Itoa(i+1)+"OptionName"] = v.OptionName + + } + params["SolutionStackName"] = options.SolutionStackName + for i, v := range options.Tags { + params["Tags.member."+strconv.Itoa(i+1)+"Key"] = v.Key + params["Tags.member."+strconv.Itoa(i+1)+"Value"] = v.Value + + } + params["TemplateName"] = options.TemplateName + + params["Tier.Name"] = options.Tier.Name + params["Tier.Type"] = options.Tier.Type + params["Tier.Version"] = options.Tier.Version + + params["VersionLabel"] = options.VersionLabel + + resp = &CreateEnvironmentResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // CheckDNSAvailability diff --git a/eb/eb_test.go b/eb/eb_test.go index a38393b9..9c8ecb1a 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -155,3 +155,35 @@ func (s *S) TestCreateConfigurationTemplate(c *C) { c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") c.Assert(resp.RequestId, Equals, "846cd905-f1fd-11df-8a78-9f77047e0d0c") } + +func (s *S) TestCreateEnvironment(c *C) { + testServer.Response(200, nil, CreateEnvironmentExample) + + options := eb.CreateEnvironment{ + ApplicationName: "SampleApp", + EnvironmentName: "SampleApp", + SolutionStackName: "32bit Amazon Linux running Tomcat 7", + Description: "EnvDescrip", + } + + resp, err := s.eb.CreateEnvironment(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateEnvironment"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["SolutionStackName"], DeepEquals, []string{"32bit Amazon Linux running Tomcat 7"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"EnvDescrip"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.DateCreated, Equals, "2010-11-17T03:59:33.520Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T03:59:33.520Z") + c.Assert(resp.Description, Equals, "EnvDescrip") + c.Assert(resp.EnvironmentId, Equals, "e-icsgecu3wf") + c.Assert(resp.EnvironmentName, Equals, "SampleApp") + c.Assert(resp.Health, Equals, "Grey") + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Status, Equals, "Deploying") + c.Assert(resp.VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "15db925e-f1ff-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 3c04d0b6..4a91cc38 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -304,6 +304,27 @@ var CreateConfigurationTemplateExample = ` ` +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateEnvironment.html +var CreateEnvironmentExample = ` + + + Version1 + Deploying + SampleApp + Grey + e-icsgecu3wf + 2010-11-17T03:59:33.520Z + 32bit Amazon Linux running Tomcat 7 + EnvDescrip + SampleApp + 2010-11-17T03:59:33.520Z + + + 15db925e-f1ff-11df-8a78-9f77047e0d0c + + +` + // http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DeleteApplication.html var DeleteApplicationExample = ` From 88e9a07a83188faaaa367dc5e2eb493efbfd8a7a Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 27 Oct 2014 00:28:17 -0700 Subject: [PATCH 09/33] Added CreateStorageLocation method --- eb/eb.go | 23 +++++++++++++++++++++++ eb/eb_test.go | 11 +++++++++++ eb/responses_test.go | 12 ++++++++++++ 3 files changed, 46 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 3f670609..a6920e7d 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -344,6 +344,29 @@ func (eb *EB) CreateEnvironment(options *CreateEnvironment) (resp *CreateEnviron return } +// CreateStorageLocation + +type CreateStorageLocationResp struct { + S3Bucket string `xml:"CreateStorageLocationResult>S3Bucket"` + RequestId string `xml:"ResponseMetadata>RequestId"` + +} + +func (eb *EB) CreateStorageLocation() (resp *CreateStorageLocationResp, err error) { + params := makeParams("CreateStorageLocation") + + resp = &CreateStorageLocationResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + + // ---------------------------------------------------------------------------- // CheckDNSAvailability diff --git a/eb/eb_test.go b/eb/eb_test.go index 9c8ecb1a..88465c43 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -187,3 +187,14 @@ func (s *S) TestCreateEnvironment(c *C) { c.Assert(resp.VersionLabel, Equals, "Version1") c.Assert(resp.RequestId, Equals, "15db925e-f1ff-11df-8a78-9f77047e0d0c") } + +func (s *S) TestCreateStorageLocation(c *C) { + testServer.Response(200, nil, CreateStorageLocationExample) + + resp, err := s.eb.CreateStorageLocation() + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateStorageLocation"}) + c.Assert(err, IsNil) + c.Assert(resp.S3Bucket, Equals, "elasticbeanstalk-us-east-1-780612358023") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 4a91cc38..32186653 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -325,6 +325,18 @@ var CreateEnvironmentExample = ` ` +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateStorageLocation.html +var CreateStorageLocationExample = ` + + + elasticbeanstalk-us-east-1-780612358023 + + + ef51b94a-f1d6-11df-8a78-9f77047e0d0c + + +` + // http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DeleteApplication.html var DeleteApplicationExample = ` From 85c26c80775feb71f1af7affc0158aca276f7a3f Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 27 Oct 2014 00:35:21 -0700 Subject: [PATCH 10/33] Go fmt --- eb/eb.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eb/eb.go b/eb/eb.go index a6920e7d..bd4fc05c 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -347,9 +347,8 @@ func (eb *EB) CreateEnvironment(options *CreateEnvironment) (resp *CreateEnviron // CreateStorageLocation type CreateStorageLocationResp struct { - S3Bucket string `xml:"CreateStorageLocationResult>S3Bucket"` - RequestId string `xml:"ResponseMetadata>RequestId"` - + S3Bucket string `xml:"CreateStorageLocationResult>S3Bucket"` + RequestId string `xml:"ResponseMetadata>RequestId"` } func (eb *EB) CreateStorageLocation() (resp *CreateStorageLocationResp, err error) { @@ -366,7 +365,6 @@ func (eb *EB) CreateStorageLocation() (resp *CreateStorageLocationResp, err erro return } - // ---------------------------------------------------------------------------- // CheckDNSAvailability From a7964a88a947bab05b5f90a357e331b4b9a21b5d Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 27 Oct 2014 00:37:03 -0700 Subject: [PATCH 11/33] Added support for DeleteApplicationVersion method --- eb/eb.go | 28 +++++++++++++++++++++++++ eb/eb_test.go | 50 ++++++++++++++++++++++++++++++-------------- eb/responses_test.go | 9 ++++++++ 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/eb/eb.go b/eb/eb.go index bd4fc05c..374584bd 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -422,6 +422,34 @@ func (eb *EB) DeleteApplication(options *DeleteApplication) (resp *SimpleResp, e return } +// DeleteApplicationVersion +type DeleteApplicationVersion struct { + ApplicationName string + DeleteSourceBundle bool + VersionLabel string +} + +func (eb *EB) DeleteApplicationVersion(options *DeleteApplicationVersion) (resp *SimpleResp, err error) { + params := makeParams("DeleteApplicationVersion") + + params["ApplicationName"] = options.ApplicationName + params["VersionLabel"] = options.VersionLabel + + if options.DeleteSourceBundle { + params["DeleteSourceBundle"] = "true" + } + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index 88465c43..b7c3fb95 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -53,22 +53,6 @@ func (s *S) TestCreateApplication(c *C) { c.Assert(resp.RequestId, Equals, "8b00e053-f1d6-11df-8a78-9f77047e0d0c") } -func (s *S) TestDeleteLoadBalancer(c *C) { - testServer.Response(200, nil, DeleteApplicationExample) - - options := eb.DeleteApplication{ - ApplicationName: "foobar", - } - - resp, err := s.eb.DeleteApplication(&options) - req := testServer.WaitRequest() - - c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteApplication"}) - c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"foobar"}) - c.Assert(err, IsNil) - c.Assert(resp.RequestId, Equals, "1f155abd-f1d7-11df-8a78-9f77047e0d0c") -} - func (s *S) TestCheckDNSAvailability(c *C) { testServer.Response(200, nil, CheckDNSAvailabilityExample) @@ -198,3 +182,37 @@ func (s *S) TestCreateStorageLocation(c *C) { c.Assert(err, IsNil) c.Assert(resp.S3Bucket, Equals, "elasticbeanstalk-us-east-1-780612358023") } + +func (s *S) TestDeleteApplication(c *C) { + testServer.Response(200, nil, DeleteApplicationExample) + + options := eb.DeleteApplication{ + ApplicationName: "foobar", + } + + resp, err := s.eb.DeleteApplication(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteApplication"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"foobar"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "1f155abd-f1d7-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDeleteApplicationVersion(c *C) { + testServer.Response(200, nil, DeleteApplicationVersionExample) + + options := eb.DeleteApplicationVersion{ + ApplicationName: "SampleApp", + VersionLabel: "First Release", + } + + resp, err := s.eb.DeleteApplicationVersion(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteApplicationVersion"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["VersionLabel"], DeepEquals, []string{"First Release"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "58dc7339-f272-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 32186653..5648b591 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -345,3 +345,12 @@ var DeleteApplicationExample = ` ` + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DeleteApplicationVersion.html +var DeleteApplicationVersionExample = ` + + + 58dc7339-f272-11df-8a78-9f77047e0d0c + + +` From 2d5c976525549639e7e823a6af4cff8f065c42a5 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 27 Oct 2014 00:40:48 -0700 Subject: [PATCH 12/33] Added DeleteConfigurationTemplate method --- eb/eb.go | 24 ++++++++++++++++++++++++ eb/eb_test.go | 18 ++++++++++++++++++ eb/responses_test.go | 8 ++++++++ 3 files changed, 50 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 374584bd..820f6d98 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -450,6 +450,30 @@ func (eb *EB) DeleteApplicationVersion(options *DeleteApplicationVersion) (resp return } +//DeleteConfigurationTemplate + +type DeleteConfigurationTemplate struct { + ApplicationName string + TemplateName string +} + +func (eb *EB) DeleteConfigurationTemplate(options *DeleteConfigurationTemplate) (resp *SimpleResp, err error) { + params := makeParams("DeleteConfigurationTemplate") + + params["ApplicationName"] = options.ApplicationName + params["TemplateName"] = options.TemplateName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index b7c3fb95..94e8c4dc 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -216,3 +216,21 @@ func (s *S) TestDeleteApplicationVersion(c *C) { c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "58dc7339-f272-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDeleteConfigurationTemplate(c *C) { + testServer.Response(200, nil, DeleteConfigurationTemplateExample) + + options := eb.DeleteConfigurationTemplate{ + ApplicationName: "SampleApp", + TemplateName: "SampleAppTemplate", + } + + resp, err := s.eb.DeleteConfigurationTemplate(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteConfigurationTemplate"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"SampleAppTemplate"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "af9cf1b6-f25e-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 5648b591..684aec05 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -354,3 +354,11 @@ var DeleteApplicationVersionExample = ` ` + +var DeleteConfigurationTemplateExample = ` + + + af9cf1b6-f25e-11df-8a78-9f77047e0d0c + + +` From 31f720f54956deefb1532b2a58fa762ca49fde4a Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 27 Oct 2014 00:44:37 -0700 Subject: [PATCH 13/33] Added DeleteEnvironmentConfiguration method --- eb/eb.go | 23 +++++++++++++++++++++++ eb/eb_test.go | 18 ++++++++++++++++++ eb/responses_test.go | 8 ++++++++ 3 files changed, 49 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 820f6d98..720d62d1 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -474,6 +474,29 @@ func (eb *EB) DeleteConfigurationTemplate(options *DeleteConfigurationTemplate) return } +// DeleteEnvironmentConfiguration +type DeleteEnvironmentConfiguration struct { + ApplicationName string + EnvironmentName string +} + +func (eb *EB) DeleteEnvironmentConfiguration(options *DeleteEnvironmentConfiguration) (resp *SimpleResp, err error) { + params := makeParams("DeleteEnvironmentConfiguration") + + params["ApplicationName"] = options.ApplicationName + params["EnvironmentName"] = options.EnvironmentName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index 94e8c4dc..592894d5 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -234,3 +234,21 @@ func (s *S) TestDeleteConfigurationTemplate(c *C) { c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "af9cf1b6-f25e-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDeleteEnvironmentConfiguration(c *C) { + testServer.Response(200, nil, DeleteEnvironmentConfigurationExample) + + options := eb.DeleteEnvironmentConfiguration{ + ApplicationName: "SampleApp", + EnvironmentName: "SampleAppEnv", + } + + resp, err := s.eb.DeleteEnvironmentConfiguration(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteEnvironmentConfiguration"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppEnv"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "fdf76507-f26d-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 684aec05..6ab0a1da 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -362,3 +362,11 @@ var DeleteConfigurationTemplateExample = ` ` + +var DeleteEnvironmentConfigurationExample = ` + + + fdf76507-f26d-11df-8a78-9f77047e0d0c + + +` From 3765d700a21e332ab17574b036e599424d244d13 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 27 Oct 2014 22:00:12 +1100 Subject: [PATCH 14/33] Refactoring to extract common types extracted ApplicationDescription and ApplicationVersionDescription --- eb/eb.go | 127 +++++++++++++++++++++++++++----------------------- eb/eb_test.go | 24 +++++----- 2 files changed, 81 insertions(+), 70 deletions(-) diff --git a/eb/eb.go b/eb/eb.go index 720d62d1..85c09b0e 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -85,6 +85,72 @@ func makeParams(action string) map[string]string { return params } +// ---------------------------------------------------------------------------- +// EB objects + +type S3Location struct { + S3Bucket string + S3Key string +} + +type ConfigurationOptionSetting struct { + Namespace string + OptionName string + Value string +} + +type SourceConfiguration struct { + ApplicationName string + TemplateName string +} + +type OptionSpecification struct { + Namespace string + OptionName string +} + +type Tag struct { + Key string `xml:"Key"` + Value string `xml:"Value"` +} + +type EnvironmentTier struct { + Name string + Type string + Version string +} +type Listener struct { + Port int + Protocol string +} +type LoadBalancerDescription struct { + Domain string + Listeners []Listener + LoadBalancerName string +} + +type EnvironmentResourcesDescription struct { + LoadBalancer LoadBalancerDescription +} + +type ApplicationDescription struct { + ApplicationName string `xml:"ApplicationName"` + ConfigurationTemplates []string `xml:"ConfigurationTemplates>member"` + DateCreated string `xml:"DateCreated"` + DateUpdated string `xml:DateUpdated"` + Description string `xml:Description"` + Versions []string `xml:Versions>member"` +} + +type ApplicationVersionDescription struct { + ApplicationName string `xml:"ApplicationName"` + DateCreated string `xml:"DateCreated"` + DateUpdated string `xml:"DateUpdated"` + Description string `xml:"Description"` + SourceBundle S3Location `xml:"SourceBundle"` + VersionLabel string `xml:"VersionLabel"` +} + // ---------------------------------------------------------------------------- // Create @@ -95,13 +161,8 @@ type CreateApplication struct { } type CreateApplicationResp struct { - ApplicationName string `xml:"CreateApplicationResult>Application>ApplicationName"` - ConfigurationTemplates []string `xml:"CreateApplicationResult>Application>ConfigurationTemplates>member"` - DateCreated string `xml:"CreateApplicationResult>Application>DateCreated"` - DateUpdated string `xml:"CreateApplicationResult>Application>DateUpdated"` - Description string `xml:"CreateApplicationResult>Application>Description"` - Versions []string `xml:"CreateApplicationResult>Application>Versions>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` + Application ApplicationDescription `xml:"CreateApplicationResult>Application"` + RequestId string `xml:"ResponseMetadata>RequestId"` } func (eb *EB) CreateApplication(options *CreateApplication) (resp *CreateApplicationResp, err error) { @@ -123,11 +184,6 @@ func (eb *EB) CreateApplication(options *CreateApplication) (resp *CreateApplica // ---------------------------------------------------------------------------- // http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplicationVersion.html -type S3Location struct { - S3Bucket string - S3Key string -} - // The CreateApplicationVersion request parameters type CreateApplicationVersion struct { ApplicationName string @@ -138,12 +194,7 @@ type CreateApplicationVersion struct { } type CreateApplicationVersionResp struct { - ApplicationName string `xml:"CreateApplicationVersionResult>ApplicationVersion>ApplicationName"` - DateCreated string `xml:"CreateApplicationVersionResult>ApplicationVersion>DateCreated"` - DateUpdated string `xml:"CreateApplicationVersionResult>ApplicationVersion>DateUpdated"` - Description string `xml:"CreateApplicationVersionResult>ApplicationVersion>Description"` - SourceBundle S3Location `xml:"CreateApplicationVersionResult>ApplicationVersion>SourceBundle"` - VersionLabel string `xml:"CreateApplicationVersionResult>ApplicationVersion>VersionLabel"` + ApplicationVersion ApplicationVersionDescription `xml:"CreateApplicationVersionResult>ApplicationVersion"` RequestId string `xml:"ResponseMetadata>RequestId"` } @@ -172,17 +223,6 @@ func (eb *EB) CreateApplicationVersion(options *CreateApplicationVersion) (resp // CreateConfigurationTemplate -type ConfigurationOptionSetting struct { - Namespace string - OptionName string - Value string -} - -type SourceConfiguration struct { - ApplicationName string - TemplateName string -} - type CreateConfigurationTemplate struct { ApplicationName string Description string @@ -238,35 +278,6 @@ func (eb *EB) CreateConfigurationTemplate(options *CreateConfigurationTemplate) // CreateEnvironment // http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateEnvironment.html -type OptionSpecification struct { - Namespace string - OptionName string -} - -type Tag struct { - Key string `xml:"Key"` - Value string `xml:"Value"` -} - -type EnvironmentTier struct { - Name string - Type string - Version string -} -type Listener struct { - Port int - Protocol string -} -type LoadBalancerDescription struct { - Domain string - Listeners []Listener - LoadBalancerName string -} - -type EnvironmentResourcesDescription struct { - LoadBalancer LoadBalancerDescription -} - type CreateEnvironment struct { ApplicationName string CNAMEPrefix string diff --git a/eb/eb_test.go b/eb/eb_test.go index 592894d5..ab1a31a4 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -45,11 +45,11 @@ func (s *S) TestCreateApplication(c *C) { c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) c.Assert(req.Form["Description"], DeepEquals, []string{"Sample Description"}) c.Assert(err, IsNil) - c.Assert(resp.ApplicationName, Equals, "SampleApp") - c.Assert(resp.ConfigurationTemplates, DeepEquals, []string{"Default"}) - c.Assert(resp.DateCreated, Equals, "2010-11-16T23:09:20.256Z") - c.Assert(resp.DateUpdated, Equals, "2010-11-16T23:09:20.256Z") - c.Assert(resp.Description, Equals, "Sample Description") + c.Assert(resp.Application.ApplicationName, Equals, "SampleApp") + c.Assert(resp.Application.ConfigurationTemplates, DeepEquals, []string{"Default"}) + c.Assert(resp.Application.DateCreated, Equals, "2010-11-16T23:09:20.256Z") + c.Assert(resp.Application.DateUpdated, Equals, "2010-11-16T23:09:20.256Z") + c.Assert(resp.Application.Description, Equals, "Sample Description") c.Assert(resp.RequestId, Equals, "8b00e053-f1d6-11df-8a78-9f77047e0d0c") } @@ -96,13 +96,13 @@ func (s *S) TestCreateApplicationVersion(c *C) { c.Assert(req.Form["SourceBundle.S3Bucket"], DeepEquals, []string{"amazonaws.com"}) c.Assert(req.Form["SourceBundle.S3Key"], DeepEquals, []string{"sample.war"}) c.Assert(err, IsNil) - c.Assert(resp.ApplicationName, Equals, "SampleApp") - c.Assert(resp.DateCreated, Equals, "2010-11-17T03:21:59.161Z") - c.Assert(resp.DateUpdated, Equals, "2010-11-17T03:21:59.161Z") - c.Assert(resp.Description, Equals, "description") - c.Assert(resp.SourceBundle.S3Bucket, Equals, "amazonaws.com") - c.Assert(resp.SourceBundle.S3Key, Equals, "sample.war") - c.Assert(resp.VersionLabel, Equals, "Version1") + c.Assert(resp.ApplicationVersion.ApplicationName, Equals, "SampleApp") + c.Assert(resp.ApplicationVersion.DateCreated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.ApplicationVersion.DateUpdated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.ApplicationVersion.Description, Equals, "description") + c.Assert(resp.ApplicationVersion.SourceBundle.S3Bucket, Equals, "amazonaws.com") + c.Assert(resp.ApplicationVersion.SourceBundle.S3Key, Equals, "sample.war") + c.Assert(resp.ApplicationVersion.VersionLabel, Equals, "Version1") c.Assert(resp.RequestId, Equals, "d653efef-f1f9-11df-8a78-9f77047e0d0c") } From 3a219233aba1b806a99475424ee87c490b14ba61 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 27 Oct 2014 22:11:50 +1100 Subject: [PATCH 15/33] Added DescribeApplicationVersions method --- eb/eb.go | 37 ++++++++++++++++++++++++++++++++++++- eb/eb_test.go | 23 +++++++++++++++++++++++ eb/responses_test.go | 23 +++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/eb/eb.go b/eb/eb.go index 85c09b0e..721e610f 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -195,7 +195,7 @@ type CreateApplicationVersion struct { type CreateApplicationVersionResp struct { ApplicationVersion ApplicationVersionDescription `xml:"CreateApplicationVersionResult>ApplicationVersion"` - RequestId string `xml:"ResponseMetadata>RequestId"` + RequestId string `xml:"ResponseMetadata>RequestId"` } func (eb *EB) CreateApplicationVersion(options *CreateApplicationVersion) (resp *CreateApplicationVersionResp, err error) { @@ -508,6 +508,41 @@ func (eb *EB) DeleteEnvironmentConfiguration(options *DeleteEnvironmentConfigura return } +// ---------------------------------------------------------------------------- +// Describe + +// DescribeApplicationVersions + +type DescribeApplicationVersions struct { + ApplicationName string + VersionLabels []string +} + +type DescribeApplicationVersionsResp struct { + ApplicationVersions []ApplicationVersionDescription `xml:"DescribeApplicationVersionsResult>ApplicationVersions>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeApplicationVersions(options *DescribeApplicationVersions) (resp *DescribeApplicationVersionsResp, err error) { + params := makeParams("DescribeApplicationVersions") + + params["ApplicationName"] = options.ApplicationName + for i, v := range options.VersionLabels { + params["VersionLabels.member."+strconv.Itoa(i+1)] = v + + } + + resp = &DescribeApplicationVersionsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index ab1a31a4..e2baaca8 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -252,3 +252,26 @@ func (s *S) TestDeleteEnvironmentConfiguration(c *C) { c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "fdf76507-f26d-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDescribeApplicationVersions(c *C) { + testServer.Response(200, nil, DescribeApplicationVersionsExample) + + options := eb.DescribeApplicationVersions{ + ApplicationName: "SampleApp", + } + + resp, err := s.eb.DescribeApplicationVersions(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeApplicationVersions"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationVersions[0].ApplicationName, Equals, "SampleApp") + c.Assert(resp.ApplicationVersions[0].DateCreated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.ApplicationVersions[0].DateUpdated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.ApplicationVersions[0].Description, Equals, "description") + c.Assert(resp.ApplicationVersions[0].SourceBundle.S3Bucket, Equals, "amazonaws.com") + c.Assert(resp.ApplicationVersions[0].SourceBundle.S3Key, Equals, "sample.war") + c.Assert(resp.ApplicationVersions[0].VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "773cd80a-f26c-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 6ab0a1da..1ca004f6 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -370,3 +370,26 @@ var DeleteEnvironmentConfigurationExample = ` ` + +var DescribeApplicationVersionsExample = ` + + + + + + amazonaws.com + sample.war + + Version1 + description + SampleApp + 2010-11-17T03:21:59.161Z + 2010-11-17T03:21:59.161Z + + + + + 773cd80a-f26c-11df-8a78-9f77047e0d0c + + +` From 07e01c49d9482d7ddb8eefdb1e41f08a1d5903a8 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 27 Oct 2014 22:21:16 +1100 Subject: [PATCH 16/33] Added DescribeApplications method --- eb/eb.go | 29 +++++++++++++++++++++++++++++ eb/eb_test.go | 21 +++++++++++++++++++++ eb/responses_test.go | 22 ++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 721e610f..08d8a12d 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -543,6 +543,35 @@ func (eb *EB) DescribeApplicationVersions(options *DescribeApplicationVersions) return } +// DescribeApplications + +type DescribeApplications struct { + ApplicationNames []string +} + +type DescribeApplicationsResp struct { + Applications []ApplicationDescription `xml:"DescribeApplicationsResult>Applications>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeApplications(options *DescribeApplications) (resp *DescribeApplicationsResp, err error) { + params := makeParams("DescribeApplications") + + for i, v := range options.ApplicationNames { + params["ApplicationNames.member."+strconv.Itoa(i+1)] = v + } + + resp = &DescribeApplicationsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index e2baaca8..64a33ef2 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -275,3 +275,24 @@ func (s *S) TestDescribeApplicationVersions(c *C) { c.Assert(resp.ApplicationVersions[0].VersionLabel, Equals, "Version1") c.Assert(resp.RequestId, Equals, "773cd80a-f26c-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDescribeApplications(c *C) { + testServer.Response(200, nil, DescribeApplicationsExample) + + options := eb.DescribeApplications{ + ApplicationNames: []string{"SampleApplication"}, + } + + resp, err := s.eb.DescribeApplications(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeApplications"}) + c.Assert(req.Form["ApplicationNames.member.1"], DeepEquals, []string{"SampleApplication"}) + c.Assert(err, IsNil) + c.Assert(resp.Applications[0].ApplicationName, Equals, "SampleApplication") + c.Assert(resp.Applications[0].DateCreated, Equals, "2010-11-16T20:20:51.974Z") + c.Assert(resp.Applications[0].DateUpdated, Equals, "2010-11-16T20:20:51.974Z") + c.Assert(resp.Applications[0].Description, Equals, "Sample Description") + c.Assert(resp.Applications[0].ConfigurationTemplates[0], Equals, "Default") + c.Assert(resp.RequestId, Equals, "577c70ff-f1d7-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 1ca004f6..b1c45091 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -393,3 +393,25 @@ var DescribeApplicationVersionsExample = ` ` + +var DescribeApplicationsExample = ` + + + + + + Sample Description + SampleApplication + 2010-11-16T20:20:51.974Z + 2010-11-16T20:20:51.974Z + + Default + + + + + + 577c70ff-f1d7-11df-8a78-9f77047e0d0c + + +` From bc1632759cb290b40ef9578066d59b353446197d Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 07:44:15 +1100 Subject: [PATCH 17/33] Added DescribeConfigurationOptions method --- eb/eb.go | 58 +++++ eb/eb_test.go | 26 +++ eb/responses_test.go | 505 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 589 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 08d8a12d..de938447 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -151,6 +151,25 @@ type ApplicationVersionDescription struct { VersionLabel string `xml:"VersionLabel"` } +type OptionRestrictionRegex struct { + Label string + Pattern string +} + +type ConfigurationOptionDescription struct { + ChangeSeverity string + DefaultValue string + MaxLength int + MaxValue int + MinValue int + Name string + Namespace string + Regex OptionRestrictionRegex + UserDefined bool + ValueOptions []string + ValueType string +} + // ---------------------------------------------------------------------------- // Create @@ -572,6 +591,45 @@ func (eb *EB) DescribeApplications(options *DescribeApplications) (resp *Describ return } +// DescribeConfigurationOptions + +type DescribeConfigurationOptions struct { + ApplicationName string + EnvironmentName string + Options []OptionSpecification + SolutionStackName string + TemplateName string +} + +type DescribeConfigurationOptionsResp struct { + Options []ConfigurationOptionDescription `xml:"DescribeConfigurationOptionsResult>Options>member"` + SolutionStackName string `xml:"DescribeConfigurationOptionsResult>SolutionStackName"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeConfigurationOptions(options *DescribeConfigurationOptions) (resp *DescribeConfigurationOptionsResp, err error) { + params := makeParams("DescribeConfigurationOptions") + + params["ApplicationName"] = options.ApplicationName + params["EnvironmentName"] = options.EnvironmentName + for i, v := range options.Options { + params["Options.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["Options.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + } + params["SolutionStackName"] = options.SolutionStackName + params["TemplateName"] = options.TemplateName + + resp = &DescribeConfigurationOptionsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index 64a33ef2..994336d8 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -296,3 +296,29 @@ func (s *S) TestDescribeApplications(c *C) { c.Assert(resp.Applications[0].ConfigurationTemplates[0], Equals, "Default") c.Assert(resp.RequestId, Equals, "577c70ff-f1d7-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDescribeConfigurationOptions(c *C) { + testServer.Response(200, nil, DescribeConfigurationOptionsExample) + + options := eb.DescribeConfigurationOptions{ + ApplicationName: "SampleApp", + TemplateName: "default", + } + + resp, err := s.eb.DescribeConfigurationOptions(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeConfigurationOptions"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"default"}) + c.Assert(err, IsNil) + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Options[0].ChangeSeverity, Equals, "RestartEnvironment") + c.Assert(resp.Options[0].DefaultValue, Equals, "ami-6036c009") + c.Assert(resp.Options[0].MaxLength, Equals, 2000) + c.Assert(resp.Options[0].Name, Equals, "ImageId") + c.Assert(resp.Options[0].Namespace, Equals, "aws:autoscaling:launchconfiguration") + c.Assert(resp.Options[0].UserDefined, Equals, false) + c.Assert(resp.Options[0].ValueType, Equals, "Scalar") + c.Assert(resp.RequestId, Equals, "e8768900-f272-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index b1c45091..0f774ba0 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -415,3 +415,508 @@ var DescribeApplicationsExample = ` ` + +var DescribeConfigurationOptionsExample = ` + + + 32bit Amazon Linux running Tomcat 7 + + + false + RestartEnvironment + 2000 + ImageId + Scalar + ami-6036c009 + aws:autoscaling:launchconfiguration + + + false + NoInterruption + 2000 + Notification Endpoint + Scalar + + aws:elasticbeanstalk:sns:topics + + + false + RestartApplicationServer + 2000 + PARAM4 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + RestartApplicationServer + 2000 + JDBC_CONNECTION_STRING + Scalar + + aws:elasticbeanstalk:application:environment + + + false + RestartEnvironment + 2000 + SecurityGroups + Scalar + elasticbeanstalk-default + aws:autoscaling:launchconfiguration + + + false + NoInterruption + 2 + UnhealthyThreshold + Scalar + 5 + 10 + aws:elb:healthcheck + + + false + RestartEnvironment + InstanceType + + t1.micro + m1.small + + Scalar + t1.micro + aws:autoscaling:launchconfiguration + + + false + NoInterruption + Statistic + + Minimum + Maximum + Sum + Average + + Scalar + Average + aws:autoscaling:trigger + + + false + RestartEnvironment + LoadBalancerHTTPSPort + + OFF + 443 + 8443 + 5443 + + Scalar + OFF + aws:elb:loadbalancer + + + false + NoInterruption + 0 + Stickiness Cookie Expiration + Scalar + 0 + 1000000 + aws:elb:policies + + + false + RestartApplicationServer + 2000 + PARAM5 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + NoInterruption + MeasureName + + CPUUtilization + NetworkIn + NetworkOut + DiskWriteOps + DiskReadBytes + DiskReadOps + DiskWriteBytes + Latency + RequestCount + HealthyHostCount + UnhealthyHostCount + + Scalar + NetworkOut + aws:autoscaling:trigger + + + false + NoInterruption + 5 + Interval + Scalar + 30 + 300 + aws:elb:healthcheck + + + false + NoInterruption + 2000 + Application Healthcheck URL + Scalar + / + aws:elasticbeanstalk:application + + + false + NoInterruption + 2000 + Notification Topic ARN + Scalar + + aws:elasticbeanstalk:sns:topics + + + false + NoInterruption + 2000 + LowerBreachScaleIncrement + Scalar + -1 + aws:autoscaling:trigger + + + false + RestartApplicationServer + 2000 + + ^\S*$ + + + XX:MaxPermSize + Scalar + 64m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + false + NoInterruption + 2000 + UpperBreachScaleIncrement + Scalar + 1 + aws:autoscaling:trigger + + + false + NoInterruption + 1 + MinSize + Scalar + 1 + 10000 + aws:autoscaling:asg + + + false + RestartEnvironment + Custom Availability Zones + + us-east-1a + us-east-1b + us-east-1c + us-east-1d + + List + us-east-1a + aws:autoscaling:asg + + + false + RestartEnvironment + Availability Zones + + Any 1 + Any 2 + + Scalar + Any 1 + aws:autoscaling:asg + + + false + NoInterruption + LogPublicationControl + Boolean + false + aws:elasticbeanstalk:hostmanager + + + false + RestartApplicationServer + 2000 + JVM Options + Scalar + + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + false + NoInterruption + 2000 + Notification Topic Name + Scalar + + aws:elasticbeanstalk:sns:topics + + + false + RestartApplicationServer + 2000 + PARAM2 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + RestartEnvironment + LoadBalancerHTTPPort + + OFF + 80 + 8080 + + Scalar + 80 + aws:elb:loadbalancer + + + false + NoInterruption + 2 + Timeout + Scalar + 5 + 60 + aws:elb:healthcheck + + + false + NoInterruption + 1 + BreachDuration + Scalar + 2 + 600 + aws:autoscaling:trigger + + + false + RestartEnvironment + MonitoringInterval + + 1 minute + 5 minute + + Scalar + 5 minute + aws:autoscaling:launchconfiguration + + + false + RestartApplicationServer + 2000 + PARAM1 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + NoInterruption + 1 + MaxSize + Scalar + 4 + 10000 + aws:autoscaling:asg + + + false + NoInterruption + 0 + LowerThreshold + Scalar + 2000000 + 20000000 + aws:autoscaling:trigger + + + false + RestartApplicationServer + 2000 + AWS_SECRET_KEY + Scalar + + aws:elasticbeanstalk:application:environment + + + false + RestartApplicationServer + 2000 + AWS_ACCESS_KEY_ID + Scalar + + aws:elasticbeanstalk:application:environment + + + false + NoInterruption + 0 + UpperThreshold + Scalar + 6000000 + 20000000 + aws:autoscaling:trigger + + + false + NoInterruption + Notification Protocol + + http + https + email + email-json + sqs + + Scalar + email + aws:elasticbeanstalk:sns:topics + + + false + NoInterruption + Unit + + Seconds + Percent + Bytes + Bits + Count + Bytes/Second + Bits/Second + Count/Second + None + + Scalar + Bytes + aws:autoscaling:trigger + + + false + RestartApplicationServer + 2000 + + ^\S*$ + + + Xmx + Scalar + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + false + NoInterruption + 0 + Cooldown + Scalar + 360 + 10000 + aws:autoscaling:asg + + + false + NoInterruption + 1 + Period + Scalar + 1 + 600 + aws:autoscaling:trigger + + + false + RestartApplicationServer + 2000 + + ^\S*$ + + + Xms + Scalar + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + false + RestartEnvironment + 2000 + EC2KeyName + Scalar + + aws:autoscaling:launchconfiguration + + + false + NoInterruption + Stickiness Policy + Boolean + false + aws:elb:policies + + + false + RestartApplicationServer + 2000 + PARAM3 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + NoInterruption + 2 + HealthyThreshold + Scalar + 3 + 10 + aws:elb:healthcheck + + + false + RestartEnvironment + 2000 + SSLCertificateId + Scalar + + aws:elb:loadbalancer + + + + + e8768900-f272-11df-8a78-9f77047e0d0c + + +` From da5febfbd5370a062e0dc2783992d3b8af925bb6 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 08:01:24 +1100 Subject: [PATCH 18/33] Added DescribeConfigurationSettings method --- eb/eb.go | 41 +++++++ eb/eb_test.go | 27 +++++ eb/responses_test.go | 254 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 321 insertions(+), 1 deletion(-) diff --git a/eb/eb.go b/eb/eb.go index de938447..0f67a646 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -170,6 +170,16 @@ type ConfigurationOptionDescription struct { ValueType string } +type ConfigurationSettingsDescription struct { + SolutionStackName string `xml:"SolutionStackName"` + OptionSettings []ConfigurationOptionSetting `xml:"OptionSettings>member"` + Description string `xml:"Description"` + ApplicationName string `xml:"ApplicationName"` + DateCreated string `xml:"DateCreated"` + DateUpdated string `xml:"DateUpdated"` + TemplateName string `xml:"TemplateName"` +} + // ---------------------------------------------------------------------------- // Create @@ -630,6 +640,37 @@ func (eb *EB) DescribeConfigurationOptions(options *DescribeConfigurationOptions return } +// DescribeConfigurationSettings + +type DescribeConfigurationSettings struct { + ApplicationName string + EnvironmentName string + TemplateName string +} + +type DescribeConfigurationSettingsResp struct { + ConfigurationSettings []ConfigurationSettingsDescription `xml:"DescribeConfigurationSettingsResult>ConfigurationSettings>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeConfigurationSettings(options *DescribeConfigurationSettings) (resp *DescribeConfigurationSettingsResp, err error) { + params := makeParams("DescribeConfigurationSettings") + + params["ApplicationName"] = options.ApplicationName + params["EnvironmentName"] = options.EnvironmentName + params["TemplateName"] = options.TemplateName + + resp = &DescribeConfigurationSettingsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index 994336d8..9c9833b9 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -322,3 +322,30 @@ func (s *S) TestDescribeConfigurationOptions(c *C) { c.Assert(resp.Options[0].ValueType, Equals, "Scalar") c.Assert(resp.RequestId, Equals, "e8768900-f272-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDescribeConfigurationSettings(c *C) { + testServer.Response(200, nil, DescribeConfigurationSettingsExample) + + options := eb.DescribeConfigurationSettings{ + ApplicationName: "SampleApp", + TemplateName: "default", + } + + resp, err := s.eb.DescribeConfigurationSettings(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeConfigurationSettings"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"default"}) + c.Assert(err, IsNil) + c.Assert(resp.ConfigurationSettings[0].SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.ConfigurationSettings[0].OptionSettings[0].OptionName, Equals, "ImageId") + c.Assert(resp.ConfigurationSettings[0].OptionSettings[0].Value, Equals, "ami-f2f0069b") + c.Assert(resp.ConfigurationSettings[0].OptionSettings[0].Namespace, Equals, "aws:autoscaling:launchconfiguration") + c.Assert(resp.ConfigurationSettings[0].Description, Equals, "Default Configuration Template") + c.Assert(resp.ConfigurationSettings[0].ApplicationName, Equals, "SampleApp") + c.Assert(resp.ConfigurationSettings[0].TemplateName, Equals, "Default") + c.Assert(resp.ConfigurationSettings[0].DateCreated, Equals, "2010-11-17T03:20:17.832Z") + c.Assert(resp.ConfigurationSettings[0].DateUpdated, Equals, "2010-11-17T03:20:17.832Z") + c.Assert(resp.RequestId, Equals, "4bde8884-f273-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 0f774ba0..253be885 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -421,7 +421,7 @@ var DescribeConfigurationOptionsExample = ` 32bit Amazon Linux running Tomcat 7 - + false RestartEnvironment 2000 @@ -920,3 +920,255 @@ var DescribeConfigurationOptionsExample = ` ` + +var DescribeConfigurationSettingsExample = ` + + + + + 32bit Amazon Linux running Tomcat 7 + + + ImageId + ami-f2f0069b + aws:autoscaling:launchconfiguration + + + Notification Endpoint + + aws:elasticbeanstalk:sns:topics + + + PARAM4 + + aws:elasticbeanstalk:application:environment + + + JDBC_CONNECTION_STRING + + aws:elasticbeanstalk:application:environment + + + SecurityGroups + elasticbeanstalk-default + aws:autoscaling:launchconfiguration + + + UnhealthyThreshold + 5 + aws:elb:healthcheck + + + InstanceType + t1.micro + aws:autoscaling:launchconfiguration + + + Statistic + Average + aws:autoscaling:trigger + + + LoadBalancerHTTPSPort + OFF + aws:elb:loadbalancer + + + Stickiness Cookie Expiration + 0 + aws:elb:policies + + + PARAM5 + + aws:elasticbeanstalk:application:environment + + + MeasureName + NetworkOut + aws:autoscaling:trigger + + + Interval + 30 + aws:elb:healthcheck + + + Application Healthcheck URL + / + aws:elasticbeanstalk:application + + + Notification Topic ARN + + aws:elasticbeanstalk:sns:topics + + + LowerBreachScaleIncrement + -1 + aws:autoscaling:trigger + + + XX:MaxPermSize + 64m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + UpperBreachScaleIncrement + 1 + aws:autoscaling:trigger + + + MinSize + 1 + aws:autoscaling:asg + + + Custom Availability Zones + us-east-1a + aws:autoscaling:asg + + + Availability Zones + Any 1 + aws:autoscaling:asg + + + LogPublicationControl + false + aws:elasticbeanstalk:hostmanager + + + JVM Options + + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + Notification Topic Name + + aws:elasticbeanstalk:sns:topics + + + PARAM2 + + aws:elasticbeanstalk:application:environment + + + LoadBalancerHTTPPort + 80 + aws:elb:loadbalancer + + + Timeout + 5 + aws:elb:healthcheck + + + BreachDuration + 2 + aws:autoscaling:trigger + + + MonitoringInterval + 5 minute + aws:autoscaling:launchconfiguration + + + PARAM1 + + aws:elasticbeanstalk:application:environment + + + MaxSize + 4 + aws:autoscaling:asg + + + LowerThreshold + 2000000 + aws:autoscaling:trigger + + + AWS_SECRET_KEY + + aws:elasticbeanstalk:application:environment + + + AWS_ACCESS_KEY_ID + + aws:elasticbeanstalk:application:environment + + + UpperThreshold + 6000000 + aws:autoscaling:trigger + + + Notification Protocol + email + aws:elasticbeanstalk:sns:topics + + + Unit + Bytes + aws:autoscaling:trigger + + + Xmx + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + Cooldown + 360 + aws:autoscaling:asg + + + Period + 1 + aws:autoscaling:trigger + + + Xms + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + EC2KeyName + + aws:autoscaling:launchconfiguration + + + Stickiness Policy + false + aws:elb:policies + + + PARAM3 + + aws:elasticbeanstalk:application:environment + + + HealthyThreshold + 3 + aws:elb:healthcheck + + + SSLCertificateId + + aws:elb:loadbalancer + + + Default Configuration Template + SampleApp + 2010-11-17T03:20:17.832Z + Default + 2010-11-17T03:20:17.832Z + + + + + 4bde8884-f273-11df-8a78-9f77047e0d0c + + +` From a7568ecd8567fdeebe8da403a24c16d39f66a282 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 08:27:30 +1100 Subject: [PATCH 19/33] Added DescribeEnvironmentResources method --- eb/eb.go | 62 ++++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 23 ++++++++++++++++ eb/responses_test.go | 34 ++++++++++++++++++++++++ 3 files changed, 119 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 0f67a646..d665ac5a 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -129,10 +129,43 @@ type LoadBalancerDescription struct { LoadBalancerName string } +//http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_EnvironmentResourcesDescription.html type EnvironmentResourcesDescription struct { LoadBalancer LoadBalancerDescription } +type AutoScalingGroup struct { + Name string +} +type Instance struct { + Id string +} +type LaunchConfiguration struct { + Name string +} +type LoadBalancer struct { + Name string +} +type Queue struct { + Name string + URL string +} +type Trigger struct { + Name string +} + +// Bad amazon! this is going to get confusing... +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_EnvironmentResourceDescription.html +type EnvironmentResourceDescription struct { + AutoScalingGroups []AutoScalingGroup `xml:"AutoScalingGroups>member"` + EnvironmentName string `xml:"EnvironmentName"` + Instances []Instance `xml:"Instances>member"` + LaunchConfigurations []LaunchConfiguration `xml:"LaunchConfigurations>member"` + LoadBalancers []LoadBalancer `xml:"LoadBalancers>member"` + Queues []Queue `xml:"Queues>member"` + Triggers []Trigger `xml:"Triggers>member"` +} + type ApplicationDescription struct { ApplicationName string `xml:"ApplicationName"` ConfigurationTemplates []string `xml:"ConfigurationTemplates>member"` @@ -671,6 +704,35 @@ func (eb *EB) DescribeConfigurationSettings(options *DescribeConfigurationSettin return } +// DescribeEnvironmentResources + +type DescribeEnvironmentResources struct { + EnvironmentId string + EnvironmentName string +} + +type DescribeEnvironmentResourcesResp struct { + EnvironmentResources []EnvironmentResourceDescription `xml:"DescribeEnvironmentResourcesResult>EnvironmentResources"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeEnvironmentResources(options *DescribeEnvironmentResources) (resp *DescribeEnvironmentResourcesResp, err error) { + params := makeParams("DescribeEnvironmentResources") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + + resp = &DescribeEnvironmentResourcesResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index 9c9833b9..4c86a2c8 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -349,3 +349,26 @@ func (s *S) TestDescribeConfigurationSettings(c *C) { c.Assert(resp.ConfigurationSettings[0].DateUpdated, Equals, "2010-11-17T03:20:17.832Z") c.Assert(resp.RequestId, Equals, "4bde8884-f273-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDescribeEnvironmentResources(c *C) { + testServer.Response(200, nil, DescribeEnvironmentResourcesExample) + + options := eb.DescribeEnvironmentResources{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + } + + resp, err := s.eb.DescribeEnvironmentResources(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeEnvironmentResources"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(err, IsNil) + c.Assert(resp.EnvironmentResources[0].EnvironmentName, Equals, "SampleAppVersion") + c.Assert(resp.EnvironmentResources[0].AutoScalingGroups[0].Name, Equals, "elasticbeanstalk-SampleAppVersion-us-east-1c") + c.Assert(resp.EnvironmentResources[0].LoadBalancers[0].Name, Equals, "elasticbeanstalk-SampleAppVersion") + c.Assert(resp.EnvironmentResources[0].LaunchConfigurations[0].Name, Equals, "elasticbeanstalk-SampleAppVersion-hbAc8cSZH7") + c.Assert(resp.EnvironmentResources[0].Triggers[0].Name, Equals, "elasticbeanstalk-SampleAppVersion-us-east-1c") + c.Assert(resp.RequestId, Equals, "e1cb7b96-f287-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 253be885..e620a321 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1172,3 +1172,37 @@ var DescribeConfigurationSettingsExample = ` ` + +var DescribeEnvironmentResourcesExample = ` + + + + + + elasticbeanstalk-SampleAppVersion + + + + + elasticbeanstalk-SampleAppVersion-hbAc8cSZH7 + + + + + elasticbeanstalk-SampleAppVersion-us-east-1c + + + SampleAppVersion + + + elasticbeanstalk-SampleAppVersion-us-east-1c + + + + + + + e1cb7b96-f287-11df-8a78-9f77047e0d0c + + +` From f2f902d0bde4ff07fe3b03c6c8cb544e38dae08f Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 17:28:52 +1100 Subject: [PATCH 20/33] Added DescribeEnvironments method --- eb/eb.go | 61 ++++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 32 +++++++++++++++++++++++ eb/responses_test.go | 25 ++++++++++++++++++ 3 files changed, 118 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index d665ac5a..e94dd20e 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -166,6 +166,24 @@ type EnvironmentResourceDescription struct { Triggers []Trigger `xml:"Triggers>member"` } +type EnvironmentDescription struct { + ApplicationName string + CNAME string + DateCreated string + DateUpdated string + Description string + EndpointURL string + EnvironmentId string + EnvironmentName string + Health string + Resources []EnvironmentResourcesDescription + SolutionStackName string + Status string + TemplateName string + Tier EnvironmentTier + VersionLabel string +} + type ApplicationDescription struct { ApplicationName string `xml:"ApplicationName"` ConfigurationTemplates []string `xml:"ConfigurationTemplates>member"` @@ -733,6 +751,49 @@ func (eb *EB) DescribeEnvironmentResources(options *DescribeEnvironmentResources return } +// DescribeEnvironments + +type DescribeEnvironments struct { + ApplicationName string + EnvironmentIds []string + EnvironmentNames []string + IncludeDeleted bool + IncludedDeletedBackTo string + VersionLabel string +} + +type DescribeEnvironmentsResp struct { + Environments []EnvironmentDescription `xml:"DescribeEnvironmentsResult>Environments>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeEnvironments(options *DescribeEnvironments) (resp *DescribeEnvironmentsResp, err error) { + params := makeParams("DescribeEnvironments") + + params["ApplicationName"] = options.ApplicationName + for i, v := range options.EnvironmentIds { + params["EnvironmentIds.member."+strconv.Itoa(i+1)] = v + } + for i, v := range options.EnvironmentNames { + params["EnvironmentNames.member."+strconv.Itoa(i+1)] = v + } + if options.IncludeDeleted { + params["IncludeDeleted"] = "true" + } + params["IncludedDeletedBackTo"] = options.IncludedDeletedBackTo + params["VersionLabel"] = options.VersionLabel + + resp = &DescribeEnvironmentsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index 4c86a2c8..fbf56827 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -372,3 +372,35 @@ func (s *S) TestDescribeEnvironmentResources(c *C) { c.Assert(resp.EnvironmentResources[0].Triggers[0].Name, Equals, "elasticbeanstalk-SampleAppVersion-us-east-1c") c.Assert(resp.RequestId, Equals, "e1cb7b96-f287-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDescribeEnvironments(c *C) { + testServer.Response(200, nil, DescribeEnvironmentsExample) + + options := eb.DescribeEnvironments{ + ApplicationName: "SampleApp", + IncludeDeleted: true, + IncludedDeletedBackTo: "2008-11-05T06:00:00Z", + } + + resp, err := s.eb.DescribeEnvironments(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeEnvironments"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["IncludeDeleted"], DeepEquals, []string{"true"}) + c.Assert(req.Form["IncludedDeletedBackTo"], DeepEquals, []string{"2008-11-05T06:00:00Z"}) + c.Assert(err, IsNil) + c.Assert(resp.Environments[0].ApplicationName, Equals, "SampleApp") + c.Assert(resp.Environments[0].CNAME, Equals, "SampleApp-jxb293wg7n.elasticbeanstalk.amazonaws.com") + c.Assert(resp.Environments[0].DateCreated, Equals, "2010-11-17T03:59:33.520Z") + c.Assert(resp.Environments[0].DateUpdated, Equals, "2010-11-17T04:01:40.668Z") + c.Assert(resp.Environments[0].Description, Equals, "EnvDescrip") + c.Assert(resp.Environments[0].EndpointURL, Equals, "elasticbeanstalk-SampleApp-1394386994.us-east-1.elb.amazonaws.com") + c.Assert(resp.Environments[0].EnvironmentId, Equals, "e-icsgecu3wf") + c.Assert(resp.Environments[0].EnvironmentName, Equals, "SampleApp") + c.Assert(resp.Environments[0].Health, Equals, "Green") + c.Assert(resp.Environments[0].SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Environments[0].Status, Equals, "Available") + c.Assert(resp.Environments[0].VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "44790c68-f260-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index e620a321..515441d1 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1206,3 +1206,28 @@ var DescribeEnvironmentResourcesExample = ` ` +var DescribeEnvironmentsExample = ` + + + + + Version1 + Available + SampleApp + elasticbeanstalk-SampleApp-1394386994.us-east-1.elb.amazonaws.com + SampleApp-jxb293wg7n.elasticbeanstalk.amazonaws.com + Green + e-icsgecu3wf + 2010-11-17T04:01:40.668Z + 32bit Amazon Linux running Tomcat 7 + EnvDescrip + SampleApp + 2010-11-17T03:59:33.520Z + + + + + 44790c68-f260-11df-8a78-9f77047e0d0c + + +` From 567927b0f5182a005c1dc2cb4283cf94f14014f7 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 17:42:24 +1100 Subject: [PATCH 21/33] Added DescribeEvents method --- eb/eb.go | 59 ++++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 27 ++++++++++++++++++++ eb/responses_test.go | 46 ++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index e94dd20e..01ecd37a 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -184,6 +184,17 @@ type EnvironmentDescription struct { VersionLabel string } +type EventDescription struct { + ApplicationName string + EnvironmentName string + EventDate string + Message string + RequestId string + Severity string + TemplateName string + VersionLabel string +} + type ApplicationDescription struct { ApplicationName string `xml:"ApplicationName"` ConfigurationTemplates []string `xml:"ConfigurationTemplates>member"` @@ -794,6 +805,54 @@ func (eb *EB) DescribeEnvironments(options *DescribeEnvironments) (resp *Describ return } +// DescribeEvents + +type DescribeEvents struct { + ApplicationName string + EndTime string + EnvironmentId string + EnvironmentName string + MaxRecords string + NextToken string + RequestId string + Severity string + StartTime string + TemplateName string + VersionLabel string +} + +type DescribeEventsResp struct { + Events []EventDescription `xml:"DescribeEventsResult>Events>member"` + NextToken string `xml:"DescribeEventsResult>NextToken"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeEvents(options *DescribeEvents) (resp *DescribeEventsResp, err error) { + params := makeParams("DescribeEvents") + + params["ApplicationName"] = options.ApplicationName + params["EndTime"] = options.EndTime + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + params["MaxRecords"] = options.MaxRecords + params["NextToken"] = options.NextToken + params["RequestId"] = options.RequestId + params["Severity"] = options.Severity + params["StartTime"] = options.StartTime + params["TemplateName"] = options.TemplateName + params["VersionLabel"] = options.VersionLabel + + resp = &DescribeEventsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index fbf56827..1f5b294b 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -404,3 +404,30 @@ func (s *S) TestDescribeEnvironments(c *C) { c.Assert(resp.Environments[0].VersionLabel, Equals, "Version1") c.Assert(resp.RequestId, Equals, "44790c68-f260-11df-8a78-9f77047e0d0c") } + +func (s *S) TestDescribeEvents(c *C) { + testServer.Response(200, nil, DescribeEventsExample) + + options := eb.DescribeEvents{ + ApplicationName: "SampleApp", + Severity: "TRACE", + StartTime: "2010-11-17T10:26:40Z", + } + + resp, err := s.eb.DescribeEvents(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeEvents"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Severity"], DeepEquals, []string{"TRACE"}) + c.Assert(req.Form["StartTime"], DeepEquals, []string{"2010-11-17T10:26:40Z"}) + c.Assert(err, IsNil) + c.Assert(resp.Events[0].ApplicationName, Equals, "SampleApp") + c.Assert(resp.Events[0].EnvironmentName, Equals, "SampleAppVersion") + c.Assert(resp.Events[0].EventDate, Equals, "2010-11-17T20:25:35.191Z") + c.Assert(resp.Events[0].Message, Equals, "Successfully completed createEnvironment activity.") + c.Assert(resp.Events[0].RequestId, Equals, "bb01fa74-f287-11df-8a78-9f77047e0d0c") + c.Assert(resp.Events[0].Severity, Equals, "INFO") + c.Assert(resp.Events[0].VersionLabel, Equals, "New Version") + c.Assert(resp.RequestId, Equals, "f10d02dd-f288-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 515441d1..d058625c 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1231,3 +1231,49 @@ var DescribeEnvironmentsExample = ` ` + +var DescribeEventsExample = ` + + + + + Successfully completed createEnvironment activity. + 2010-11-17T20:25:35.191Z + New Version + bb01fa74-f287-11df-8a78-9f77047e0d0c + SampleApp + SampleAppVersion + INFO + + + Launching a new EC2 instance: i-04a8c569 + 2010-11-17T20:21:30Z + New Version + SampleApp + SampleAppVersion + DEBUG + + + At least one EC2 instance has entered the InService lifecycle state. + 2010-11-17T20:20:32.008Z + New Version + bb01fa74-f287-11df-8a78-9f77047e0d0c + SampleApp + SampleAppVersion + INFO + + + Elastic Load Balancer elasticbeanstalk-SampleAppVersion has failed 0 healthy instances - Environment may not be available. + 2010-11-17T20:19:28Z + New Version + SampleApp + SampleAppVersion + WARN + + + + + f10d02dd-f288-11df-8a78-9f77047e0d0c + + +` From 82490215fd343ddef4bc2479f316258bd6910f60 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 17:58:46 +1100 Subject: [PATCH 22/33] Added ListAvailableSolutionStacks method --- eb/eb.go | 33 +++++++++++++++++++++++++++++++-- eb/eb_test.go | 13 +++++++++++++ eb/responses_test.go | 15 +++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/eb/eb.go b/eb/eb.go index 01ecd37a..02c69770 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -823,8 +823,8 @@ type DescribeEvents struct { type DescribeEventsResp struct { Events []EventDescription `xml:"DescribeEventsResult>Events>member"` - NextToken string `xml:"DescribeEventsResult>NextToken"` - RequestId string `xml:"ResponseMetadata>RequestId"` + NextToken string `xml:"DescribeEventsResult>NextToken"` + RequestId string `xml:"ResponseMetadata>RequestId"` } func (eb *EB) DescribeEvents(options *DescribeEvents) (resp *DescribeEventsResp, err error) { @@ -853,6 +853,35 @@ func (eb *EB) DescribeEvents(options *DescribeEvents) (resp *DescribeEventsResp, return } +// ---------------------------------------------------------------------------- +// List + +type SolutionStackDescription struct { + PermittedFileTypes []string + SolutionStackName string +} + +type ListAvailableSolutionStacksResp struct { + SolutionStackDetails []SolutionStackDescription `xml:"ListAvailableSolutionStacksResult>SolutionStackDetails"` + SolutionStacks []string `xml:"ListAvailableSolutionStacksResult>SolutionStacks>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) ListAvailableSolutionStacks() (resp *ListAvailableSolutionStacksResp, err error) { + params := makeParams("ListAvailableSolutionStacks") + + resp = &ListAvailableSolutionStacksResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- // Responses type SimpleResp struct { diff --git a/eb/eb_test.go b/eb/eb_test.go index 1f5b294b..2dbdd074 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -431,3 +431,16 @@ func (s *S) TestDescribeEvents(c *C) { c.Assert(resp.Events[0].VersionLabel, Equals, "New Version") c.Assert(resp.RequestId, Equals, "f10d02dd-f288-11df-8a78-9f77047e0d0c") } + +func (s *S) TestListAvailableSolutionStacks(c *C) { + testServer.Response(200, nil, ListAvailableSolutionStacksExample) + + resp, err := s.eb.ListAvailableSolutionStacks() + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"ListAvailableSolutionStacks"}) + c.Assert(err, IsNil) + c.Assert(resp.SolutionStacks[0], Equals, "64bit Amazon Linux running Tomcat 6") + c.Assert(resp.SolutionStacks[1], Equals, "32bit Amazon Linux running Tomcat 6") + c.Assert(resp.RequestId, Equals, "f21e2a92-f1fc-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index d058625c..eb8efa79 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1277,3 +1277,18 @@ var DescribeEventsExample = ` ` +var ListAvailableSolutionStacksExample = ` + + + + 64bit Amazon Linux running Tomcat 6 + 32bit Amazon Linux running Tomcat 6 + 64bit Amazon Linux running Tomcat 7 + 32bit Amazon Linux running Tomcat 7 + + + + f21e2a92-f1fc-11df-8a78-9f77047e0d0c + + +` From fda6c29a21087dfd144742149c186dae1c1ab0c3 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 18:04:15 +1100 Subject: [PATCH 23/33] Added RebuildEnvironment method --- eb/eb.go | 27 +++++++++++++++++++++++++++ eb/eb_test.go | 16 ++++++++++++++++ eb/responses_test.go | 8 ++++++++ 3 files changed, 51 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 02c69770..a4ba2edf 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -881,6 +881,33 @@ func (eb *EB) ListAvailableSolutionStacks() (resp *ListAvailableSolutionStacksRe return } +// ---------------------------------------------------------------------------- +// Rebuild + +// RebuildEnvironment + +type RebuildEnvironment struct { + EnvironmentId string + EnvironmentName string +} + +func (eb *EB) RebuildEnvironment(options *RebuildEnvironment) (resp *SimpleResp, err error) { + params := makeParams("RebuildEnvironment") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index 2dbdd074..b06306b5 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -444,3 +444,19 @@ func (s *S) TestListAvailableSolutionStacks(c *C) { c.Assert(resp.SolutionStacks[1], Equals, "32bit Amazon Linux running Tomcat 6") c.Assert(resp.RequestId, Equals, "f21e2a92-f1fc-11df-8a78-9f77047e0d0c") } + +func (s *S) TestRebuildEnvironment(c *C) { + testServer.Response(200, nil, RebuildEnvironmentExample) + + options := eb.RebuildEnvironment{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + } + + resp, err := s.eb.RebuildEnvironment(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"RebuildEnvironment"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "a7d6606e-f289-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index eb8efa79..a478e78a 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1292,3 +1292,11 @@ var ListAvailableSolutionStacksExample = ` ` + +var RebuildEnvironmentExample = ` + + + a7d6606e-f289-11df-8a78-9f77047e0d0c + + +` From e07bb98d1645e319bb42cbf8e6db43f807e41029 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 18:09:51 +1100 Subject: [PATCH 24/33] Added RequestEnvironmentInfo method --- eb/eb.go | 26 ++++++++++++++++++++++++++ eb/eb_test.go | 20 ++++++++++++++++++++ eb/responses_test.go | 8 ++++++++ 3 files changed, 54 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index a4ba2edf..9edeaa63 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -908,6 +908,32 @@ func (eb *EB) RebuildEnvironment(options *RebuildEnvironment) (resp *SimpleResp, return } +// RequestEnvironmentInfo + +type RequestEnvironmentInfo struct { + EnvironmentId string + EnvironmentName string + InfoType string +} + +func (eb *EB) RequestEnvironmentInfo(options *RequestEnvironmentInfo) (resp *SimpleResp, err error) { + params := makeParams("RequestEnvironmentInfo") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + params["InfoType"] = options.InfoType + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index b06306b5..e232bf03 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -457,6 +457,26 @@ func (s *S) TestRebuildEnvironment(c *C) { req := testServer.WaitRequest() c.Assert(req.Form["Action"], DeepEquals, []string{"RebuildEnvironment"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "a7d6606e-f289-11df-8a78-9f77047e0d0c") } + +func (s *S) TestRequestEnvironmentInfo(c *C) { + testServer.Response(200, nil, RequestEnvironmentInfoExample) + + options := eb.RequestEnvironmentInfo{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + } + + resp, err := s.eb.RequestEnvironmentInfo(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"RequestEnvironmentInfo"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "126a4ff3-f28a-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index a478e78a..8936ba6f 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1300,3 +1300,11 @@ var RebuildEnvironmentExample = ` ` + +var RequestEnvironmentInfoExample = ` + + + 126a4ff3-f28a-11df-8a78-9f77047e0d0c + + +` From f53b71f888217880f38b6d65904419e9defc9726 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 18:11:57 +1100 Subject: [PATCH 25/33] Added RestartAppServer method --- eb/eb.go | 24 ++++++++++++++++++++++++ eb/eb_test.go | 18 ++++++++++++++++++ eb/responses_test.go | 8 ++++++++ 3 files changed, 50 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 9edeaa63..cf7bc338 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -934,6 +934,30 @@ func (eb *EB) RequestEnvironmentInfo(options *RequestEnvironmentInfo) (resp *Sim return } +// RestartAppServer + +type RestartAppServer struct { + EnvironmentId string + EnvironmentName string +} + +func (eb *EB) RestartAppServer(options *RestartAppServer) (resp *SimpleResp, err error) { + params := makeParams("RestartAppServer") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index e232bf03..00318fd9 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -480,3 +480,21 @@ func (s *S) TestRequestEnvironmentInfo(c *C) { c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "126a4ff3-f28a-11df-8a78-9f77047e0d0c") } + +func (s *S) TestRestartAppServer(c *C) { + testServer.Response(200, nil, RestartAppServerExample) + + options := eb.RestartAppServer{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + } + + resp, err := s.eb.RestartAppServer(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"RestartAppServer"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "90e8d1d5-f28a-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 8936ba6f..e398ffd1 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1308,3 +1308,11 @@ var RequestEnvironmentInfoExample = ` ` + +var RestartAppServerExample = ` + + + 90e8d1d5-f28a-11df-8a78-9f77047e0d0c + + +` From 1bd7b5d5b1d56ffdd2f5011d240379be234d5b75 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 18:23:20 +1100 Subject: [PATCH 26/33] Added RetrieveEnvironmentInfo method --- eb/eb.go | 38 ++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 24 ++++++++++++++++++++++++ eb/responses_test.go | 18 ++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index cf7bc338..9081ad3b 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -958,6 +958,44 @@ func (eb *EB) RestartAppServer(options *RestartAppServer) (resp *SimpleResp, err return } +// RetrieveEnvironmentInfo + +type EnvironmentInfoDescription struct { + Ec2InstanceId string `xml:"Ec2InstanceId"` + InfoType string `xml:"InfoType"` + Message string `xml:"Message"` + SampleTimestamp string `xml:"SampleTimestamp"` +} + +type RetrieveEnvironmentInfo struct { + EnvironmentId string + EnvironmentName string + InfoType string +} + +type RetrieveEnvironmentInfoResp struct { + EnvironmentInfo []EnvironmentInfoDescription `xml:"RetrieveEnvironmentInfoResult>EnvironmentInfo>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) RetrieveEnvironmentInfo(options *RetrieveEnvironmentInfo) (resp *RetrieveEnvironmentInfoResp, err error) { + params := makeParams("RetrieveEnvironmentInfo") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + params["InfoType"] = options.InfoType + + resp = &RetrieveEnvironmentInfoResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index 00318fd9..df7214b7 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -498,3 +498,27 @@ func (s *S) TestRestartAppServer(c *C) { c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "90e8d1d5-f28a-11df-8a78-9f77047e0d0c") } + +func (s *S) TestRetrieveEnvironmentInfo(c *C) { + testServer.Response(200, nil, RetrieveEnvironmentInfoExample) + + options := eb.RetrieveEnvironmentInfo{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + InfoType: "tail", + } + + resp, err := s.eb.RetrieveEnvironmentInfo(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"RetrieveEnvironmentInfo"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(req.Form["InfoType"], DeepEquals, []string{"tail"}) + c.Assert(err, IsNil) + c.Assert(resp.EnvironmentInfo[0].Ec2InstanceId, Equals, "i-92a3ceff") + c.Assert(resp.EnvironmentInfo[0].InfoType, Equals, "tail") + c.Assert(resp.EnvironmentInfo[0].Message, Equals, "https://elasticbeanstalk.us-east-1.s3.amazonaws.com/environments%2Fa514386a-709f-4888-9683-068c38d744b4%2Flogs%2Fi-92a3ceff%2F278756a8-7d83-4bc1-93db-b1763163705a.log?Expires=1291236023") + c.Assert(resp.EnvironmentInfo[0].SampleTimestamp, Equals, "2010-11-17T20:40:23.210Z") + c.Assert(resp.RequestId, Equals, "e8e785c9-f28a-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index e398ffd1..ea0757b4 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1316,3 +1316,21 @@ var RestartAppServerExample = ` ` + +var RetrieveEnvironmentInfoExample = ` + + + + + https://elasticbeanstalk.us-east-1.s3.amazonaws.com/environments%2Fa514386a-709f-4888-9683-068c38d744b4%2Flogs%2Fi-92a3ceff%2F278756a8-7d83-4bc1-93db-b1763163705a.log?Expires=1291236023 + 2010-11-17T20:40:23.210Z + tail + i-92a3ceff + + + + + e8e785c9-f28a-11df-8a78-9f77047e0d0c + + +` From 1f4f776229472f301e1903b7f6f96c97660f9168 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 18:31:23 +1100 Subject: [PATCH 27/33] Added SwapEnvironmentCNAMEs method --- eb/eb.go | 28 ++++++++++++++++++++++++++++ eb/eb_test.go | 18 ++++++++++++++++++ eb/responses_test.go | 8 ++++++++ 3 files changed, 54 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 9081ad3b..5bd2b563 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -996,6 +996,34 @@ func (eb *EB) RetrieveEnvironmentInfo(options *RetrieveEnvironmentInfo) (resp *R return } +// SwapEnvironmentCNAMEs + +type SwapEnvironmentCNAMEs struct { + DestinationEnvironmentId string + DestinationEnvironmentName string + SourceEnvironmentId string + SourceEnvironmentName string +} + +func (eb *EB) SwapEnvironmentCNAMEs(options *SwapEnvironmentCNAMEs) (resp *SimpleResp, err error) { + params := makeParams("SwapEnvironmentCNAMEs") + + params["DestinationEnvironmentId"] = options.DestinationEnvironmentId + params["DestinationEnvironmentName"] = options.DestinationEnvironmentName + params["SourceEnvironmentId"] = options.SourceEnvironmentId + params["SourceEnvironmentName"] = options.SourceEnvironmentName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index df7214b7..04364db2 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -522,3 +522,21 @@ func (s *S) TestRetrieveEnvironmentInfo(c *C) { c.Assert(resp.EnvironmentInfo[0].SampleTimestamp, Equals, "2010-11-17T20:40:23.210Z") c.Assert(resp.RequestId, Equals, "e8e785c9-f28a-11df-8a78-9f77047e0d0c") } + +func (s *S) TestSwapEnvironmentCNAMEs(c *C) { + testServer.Response(200, nil, SwapEnvironmentCNAMEsExample) + + options := eb.SwapEnvironmentCNAMEs{ + SourceEnvironmentName: "SampleApp", + DestinationEnvironmentName: "SampleApp2", + } + + resp, err := s.eb.SwapEnvironmentCNAMEs(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"SwapEnvironmentCNAMEs"}) + c.Assert(req.Form["SourceEnvironmentName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["DestinationEnvironmentName"], DeepEquals, []string{"SampleApp2"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "f4e1b145-9080-11e0-8e5a-a558e0ce1fc4") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index ea0757b4..2e152fa3 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1334,3 +1334,11 @@ var RetrieveEnvironmentInfoExample = ` ` + +var SwapEnvironmentCNAMEsExample = ` + + + f4e1b145-9080-11e0-8e5a-a558e0ce1fc4 + + +` From c0d5833030a2c3ac44564284259ec58815a72257 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Tue, 28 Oct 2014 18:42:38 +1100 Subject: [PATCH 28/33] Added UpdateApplication method --- eb/eb.go | 41 ++++++++++++++++++++++++++++++++++++++--- eb/eb_test.go | 24 ++++++++++++++++++++++++ eb/responses_test.go | 22 ++++++++++++++++++++++ 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/eb/eb.go b/eb/eb.go index 5bd2b563..1fea75c0 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -199,9 +199,9 @@ type ApplicationDescription struct { ApplicationName string `xml:"ApplicationName"` ConfigurationTemplates []string `xml:"ConfigurationTemplates>member"` DateCreated string `xml:"DateCreated"` - DateUpdated string `xml:DateUpdated"` - Description string `xml:Description"` - Versions []string `xml:Versions>member"` + DateUpdated string `xml:"DateUpdated"` + Description string `xml:"Description"` + Versions []string `xml:"Versions>member"` } type ApplicationVersionDescription struct { @@ -1024,6 +1024,41 @@ func (eb *EB) SwapEnvironmentCNAMEs(options *SwapEnvironmentCNAMEs) (resp *Simpl return } +// ---------------------------------------------------------------------------- +// Terminate + +// ---------------------------------------------------------------------------- +// Update + +// UpdateApplication + +type UpdateApplication struct { + ApplicationName string + Description string +} + +type UpdateApplicationResp struct { + Application ApplicationDescription `xml:"UpdateApplicationResult>Application"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) UpdateApplication(options *UpdateApplication) (resp *UpdateApplicationResp, err error) { + params := makeParams("UpdateApplication") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + + resp = &UpdateApplicationResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index 04364db2..cec9a67a 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -540,3 +540,27 @@ func (s *S) TestSwapEnvironmentCNAMEs(c *C) { c.Assert(err, IsNil) c.Assert(resp.RequestId, Equals, "f4e1b145-9080-11e0-8e5a-a558e0ce1fc4") } + +func (s *S) TestUpdateApplication(c *C) { + testServer.Response(200, nil, UpdateApplicationExample) + + options := eb.UpdateApplication{ + ApplicationName: "SampleApp", + Description: "Another Description", + } + + resp, err := s.eb.UpdateApplication(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateApplication"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"Another Description"}) + c.Assert(err, IsNil) + c.Assert(resp.Application.ApplicationName, Equals, "SampleApp") + c.Assert(resp.Application.ConfigurationTemplates[0], Equals, "Default") + c.Assert(resp.Application.DateCreated, Equals, "2010-11-17T19:26:20.410Z") + c.Assert(resp.Application.DateUpdated, Equals, "2010-11-17T20:42:54.611Z") + c.Assert(resp.Application.Description, Equals, "Another Description") + c.Assert(resp.Application.Versions[0], Equals, "New Version") + c.Assert(resp.RequestId, Equals, "40be666b-f28b-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 2e152fa3..6965ee6b 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1342,3 +1342,25 @@ var SwapEnvironmentCNAMEsExample = ` ` + +var UpdateApplicationExample = ` + + + + + New Version + + Another Description + SampleApp + 2010-11-17T19:26:20.410Z + 2010-11-17T20:42:54.611Z + + Default + + + + + 40be666b-f28b-11df-8a78-9f77047e0d0c + + +` From 2ae870a617a127dff67d8a2e10ceb1ed8251db11 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Wed, 29 Oct 2014 11:18:22 +1100 Subject: [PATCH 29/33] Added TerminateEnvironment method --- eb/eb.go | 47 ++++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 30 ++++++++++++++++++++++++++++ eb/responses_test.go | 21 ++++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index 1fea75c0..b27e104c 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -1027,6 +1027,53 @@ func (eb *EB) SwapEnvironmentCNAMEs(options *SwapEnvironmentCNAMEs) (resp *Simpl // ---------------------------------------------------------------------------- // Terminate +type TerminateEnvironment struct { + EnvironmentId string + EnvironmentName string + TerminateResources bool +} + +type TerminateEnvironmentResp struct { + ApplicationName string `xml:"TerminateEnvironmentResult>ApplicationName"` + CNAME string `xml:"TerminateEnvironmentResult>CNAME"` + DateCreated string `xml:"TerminateEnvironmentResult>DateCreated"` + DateUpdated string `xml:"TerminateEnvironmentResult>DateUpdated"` + Description string `xml:"TerminateEnvironmentResult>Description"` + EndpointURL string `xml:"TerminateEnvironmentResult>EndpointURL"` + EnvironmentId string `xml:"TerminateEnvironmentResult>EnvironmentId"` + EnvironmentName string `xml:"TerminateEnvironmentResult>EnvironmentName"` + Health string `xml:"TerminateEnvironmentResult>Health"` + Resources EnvironmentResourcesDescription `xml:"TerminateEnvironmentResult>Resources"` + SolutionStackName string `xml:"TerminateEnvironmentResult>SolutionStackName"` + Status string `xml:"TerminateEnvironmentResult>Status"` + TemplateName string `xml:"TerminateEnvironmentResult>TemplateName"` + Tier EnvironmentTier `xml:"TerminateEnvironmentResult>Tier"` + VersionLabel string `xml:"TerminateEnvironmentResult>VersionLabel"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) TerminateEnvironment(options *TerminateEnvironment) (resp *TerminateEnvironmentResp, err error) { + params := makeParams("TerminateEnvironment") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + if !options.TerminateResources { + params["TerminateResources"] = "false" + } else { + params["TerminateResources"] = "true" + } + + resp = &TerminateEnvironmentResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Update diff --git a/eb/eb_test.go b/eb/eb_test.go index cec9a67a..56d9478e 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -541,6 +541,36 @@ func (s *S) TestSwapEnvironmentCNAMEs(c *C) { c.Assert(resp.RequestId, Equals, "f4e1b145-9080-11e0-8e5a-a558e0ce1fc4") } +func (s *S) TestTerminateEnvironment(c *C) { + testServer.Response(200, nil, TerminateEnvironmentExample) + + options := eb.TerminateEnvironment{ + EnvironmentId: "e-icsgecu3wf", + EnvironmentName: "SampleApp", + } + + resp, err := s.eb.TerminateEnvironment(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"TerminateEnvironment"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-icsgecu3wf"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.CNAME, Equals, "SampleApp-jxb293wg7n.elasticbeanstalk.amazonaws.com") + c.Assert(resp.DateCreated, Equals, "2010-11-17T03:59:33.520Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T17:10:41.976Z") + c.Assert(resp.Description, Equals, "EnvDescrip") + c.Assert(resp.EndpointURL, Equals, "elasticbeanstalk-SampleApp-1394386994.us-east-1.elb.amazonaws.com") + c.Assert(resp.EnvironmentId, Equals, "e-icsgecu3wf") + c.Assert(resp.EnvironmentName, Equals, "SampleApp") + c.Assert(resp.Health, Equals, "Grey") + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Status, Equals, "Terminating") + c.Assert(resp.VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "9b71af21-f26d-11df-8a78-9f77047e0d0c") +} + func (s *S) TestUpdateApplication(c *C) { testServer.Response(200, nil, UpdateApplicationExample) diff --git a/eb/responses_test.go b/eb/responses_test.go index 6965ee6b..b0d4d26b 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1364,3 +1364,24 @@ var UpdateApplicationExample = ` ` +var TerminateEnvironmentExample = ` + + + Version1 + Terminating + SampleApp + elasticbeanstalk-SampleApp-1394386994.us-east-1.elb.amazonaws.com + SampleApp-jxb293wg7n.elasticbeanstalk.amazonaws.com + Grey + e-icsgecu3wf + 2010-11-17T17:10:41.976Z + 32bit Amazon Linux running Tomcat 7 + EnvDescrip + SampleApp + 2010-11-17T03:59:33.520Z + + + 9b71af21-f26d-11df-8a78-9f77047e0d0c + + +` From 6bd6de7f7916ea9ce6ce06a7b96aac8a94f8864a Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Sun, 2 Nov 2014 21:17:20 +1100 Subject: [PATCH 30/33] Added UpdateApplicationVersion method --- eb/eb.go | 31 +++++++++++++++++++++++++++++++ eb/eb_test.go | 27 +++++++++++++++++++++++++++ eb/responses_test.go | 23 ++++++++++++++++++++++- 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/eb/eb.go b/eb/eb.go index b27e104c..eaa29e55 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -1106,6 +1106,37 @@ func (eb *EB) UpdateApplication(options *UpdateApplication) (resp *UpdateApplica return } +// UpdateApplicationVersion + +type UpdateApplicationVersion struct { + ApplicationName string + Description string + VersionLabel string +} + +type UpdateApplicationVersionResp struct { + ApplicationVersion ApplicationVersionDescription `xml:"UpdateApplicationVersionResult>ApplicationVersion"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) UpdateApplicationVersion(options *UpdateApplicationVersion) (resp *UpdateApplicationVersionResp, err error) { + params := makeParams("UpdateApplicationVersion") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + params["VersionLabel"] = options.VersionLabel + + resp = &UpdateApplicationVersionResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index 56d9478e..6f02371d 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -594,3 +594,30 @@ func (s *S) TestUpdateApplication(c *C) { c.Assert(resp.Application.Versions[0], Equals, "New Version") c.Assert(resp.RequestId, Equals, "40be666b-f28b-11df-8a78-9f77047e0d0c") } + +func (s *S) TestUpdateApplicationVersion(c *C) { + testServer.Response(200, nil, UpdateApplicationVersionExample) + + options := eb.UpdateApplicationVersion{ + ApplicationName: "SampleApp", + Description: "New Release Description", + VersionLabel: "New Version", + } + + resp, err := s.eb.UpdateApplicationVersion(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateApplicationVersion"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"New Release Description"}) + c.Assert(req.Form["VersionLabel"], DeepEquals, []string{"New Version"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationVersion.ApplicationName, Equals, "SampleApp") + c.Assert(resp.ApplicationVersion.DateCreated, Equals, "2010-11-17T19:26:20.699Z") + c.Assert(resp.ApplicationVersion.DateUpdated, Equals, "2010-11-17T20:48:16.632Z") + c.Assert(resp.ApplicationVersion.Description, Equals, "New Release Description") + c.Assert(resp.ApplicationVersion.VersionLabel, Equals, "New Version") + c.Assert(resp.ApplicationVersion.SourceBundle.S3Key, Equals, "sample.war") + c.Assert(resp.ApplicationVersion.SourceBundle.S3Bucket, Equals, "awsemr") + c.Assert(resp.RequestId, Equals, "00b10aa1-f28c-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index b0d4d26b..cdab568e 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1170,7 +1170,7 @@ var DescribeConfigurationSettingsExample = ` 4bde8884-f273-11df-8a78-9f77047e0d0c - + ` var DescribeEnvironmentResourcesExample = ` @@ -1385,3 +1385,24 @@ var TerminateEnvironmentExample = ` ` + +var UpdateApplicationVersionExample = ` + + + + + awsemr + sample.war + + New Version + New Release Description + SampleApp + 2010-11-17T19:26:20.699Z + 2010-11-17T20:48:16.632Z + + + + 00b10aa1-f28c-11df-8a78-9f77047e0d0c + + +` From 76505ba37ab5ffd3b1fa135fdc02d3bf749fc57d Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Sun, 2 Nov 2014 22:03:12 +1100 Subject: [PATCH 31/33] Added UpdateConfigurationTemplate method --- eb/eb.go | 50 +++++++++ eb/eb_test.go | 36 +++++++ eb/responses_test.go | 243 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 329 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index eaa29e55..ddcbaef8 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -1137,6 +1137,56 @@ func (eb *EB) UpdateApplicationVersion(options *UpdateApplicationVersion) (resp return } +// UpdateConfigurationTemplate + +type UpdateConfigurationTemplate struct { + ApplicationName string + Description string + OptionSettings []ConfigurationOptionSetting + OptionsToRemove []OptionSpecification + TemplateName string +} + +type UpdateConfigurationTemplateResp struct { + ApplicationName string `xml:"UpdateConfigurationTemplateResult>ApplicationName"` + DateCreated string `xml:"UpdateConfigurationTemplateResult>DateCreated"` + DateUpdated string `xml:"UpdateConfigurationTemplateResult>DateUpdated"` + DeploymentStatus string `xml:"UpdateConfigurationTemplateResult>DeploymentStatus"` + Description string `xml:"UpdateConfigurationTemplateResult>Description"` + EnvironmentName string `xml:"UpdateConfigurationTemplateResult>EnvironmentName"` + OptionSettings []ConfigurationOptionSetting `xml:"UpdateConfigurationTemplateResult>OptionSettings>member"` + SolutionStackName string `xml:"UpdateConfigurationTemplateResult>SolutionStackName"` + TemplateName string `xml:"UpdateConfigurationTemplateResult>TemplateName"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) UpdateConfigurationTemplate(options *UpdateConfigurationTemplate) (resp *UpdateConfigurationTemplateResp, err error) { + params := makeParams("UpdateConfigurationTemplate") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+".Value"] = v.Value + } + for i, v := range options.OptionsToRemove { + params["OptionsToRemove.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionsToRemove.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + } + params["TemplateName"] = options.TemplateName + + resp = &UpdateConfigurationTemplateResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index 6f02371d..0f654030 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -621,3 +621,39 @@ func (s *S) TestUpdateApplicationVersion(c *C) { c.Assert(resp.ApplicationVersion.SourceBundle.S3Bucket, Equals, "awsemr") c.Assert(resp.RequestId, Equals, "00b10aa1-f28c-11df-8a78-9f77047e0d0c") } + +func (s *S) TestUpdateConfigurationTemplate(c *C) { + testServer.Response(200, nil, UpdateConfigurationTemplateExample) + + options := eb.UpdateConfigurationTemplate{ + ApplicationName: "SampleApp", + Description: "changed description", + OptionSettings: []eb.ConfigurationOptionSetting{{ + Namespace: "aws.autoscaling.trigger", + OptionName: "LowerThreshold", + Value: "1000000", + }}, + OptionsToRemove: []eb.OptionSpecification{}, + TemplateName: "default", + } + + resp, err := s.eb.UpdateConfigurationTemplate(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateConfigurationTemplate"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"changed description"}) + c.Assert(req.Form["OptionSettings.member.1.Namespace"], DeepEquals, []string{"aws.autoscaling.trigger"}) + c.Assert(req.Form["OptionSettings.member.1.OptionName"], DeepEquals, []string{"LowerThreshold"}) + c.Assert(req.Form["OptionSettings.member.1.Value"], DeepEquals, []string{"1000000"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"default"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.TemplateName, Equals, "Default") + c.Assert(resp.OptionSettings[0].OptionName, Equals, "Availability Zones") + c.Assert(resp.OptionSettings[0].Value, Equals, "Any 1") + c.Assert(resp.OptionSettings[0].Namespace, Equals, "aws:autoscaling:asg") + c.Assert(resp.DateCreated, Equals, "2010-11-17T19:26:20.420Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T20:58:27.508Z") + c.Assert(resp.RequestId, Equals, "6cbcb09a-f28d-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index cdab568e..a4acf7ad 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1406,3 +1406,246 @@ var UpdateApplicationVersionExample = ` ` + +var UpdateConfigurationTemplateExample = ` + + + 32bit Amazon Linux running Tomcat 7 + + + Availability Zones + Any 1 + aws:autoscaling:asg + + + PARAM5 + + aws:elasticbeanstalk:application:environment + + + LowerThreshold + 1000000 + aws:autoscaling:trigger + + + UpperThreshold + 9000000 + aws:autoscaling:trigger + + + LowerBreachScaleIncrement + -1 + aws:autoscaling:trigger + + + MeasureName + NetworkOut + aws:autoscaling:trigger + + + Period + 60 + aws:autoscaling:trigger + + + Xmx + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + PARAM3 + + aws:elasticbeanstalk:application:environment + + + EC2KeyName + + aws:autoscaling:launchconfiguration + + + MinSize + 1 + aws:autoscaling:asg + + + JVM Options + + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + XX:MaxPermSize + 64m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + AWS_SECRET_KEY + + aws:elasticbeanstalk:application:environment + + + UpperBreachScaleIncrement + 1 + aws:autoscaling:trigger + + + Notification Topic ARN + + aws:elasticbeanstalk:sns:topics + + + InstanceType + t1.micro + aws:autoscaling:launchconfiguration + + + Custom Availability Zones + us-east-1a + aws:autoscaling:asg + + + Statistic + Average + aws:autoscaling:trigger + + + Notification Protocol + email + aws:elasticbeanstalk:sns:topics + + + JDBC_CONNECTION_STRING + + aws:elasticbeanstalk:application:environment + + + PARAM2 + + aws:elasticbeanstalk:application:environment + + + Stickiness Cookie Expiration + 0 + aws:elb:policies + + + SSLCertificateId + + aws:elb:loadbalancer + + + MaxSize + 4 + aws:autoscaling:asg + + + Stickiness Policy + false + aws:elb:policies + + + Notification Topic Name + + aws:elasticbeanstalk:sns:topics + + + SecurityGroups + elasticbeanstalk-default + aws:autoscaling:launchconfiguration + + + LoadBalancerHTTPPort + 80 + aws:elb:loadbalancer + + + Unit + None + aws:autoscaling:trigger + + + AWS_ACCESS_KEY_ID + + aws:elasticbeanstalk:application:environment + + + PARAM4 + + aws:elasticbeanstalk:application:environment + + + Application Healthcheck URL + / + aws:elasticbeanstalk:application + + + LoadBalancerHTTPSPort + OFF + aws:elb:loadbalancer + + + HealthyThreshold + 3 + aws:elb:healthcheck + + + Timeout + 5 + aws:elb:healthcheck + + + Cooldown + 0 + aws:autoscaling:asg + + + UnhealthyThreshold + 5 + aws:elb:healthcheck + + + Interval + 30 + aws:elb:healthcheck + + + LogPublicationControl + false + aws:elasticbeanstalk:hostmanager + + + BreachDuration + 120 + aws:autoscaling:trigger + + + PARAM1 + + aws:elasticbeanstalk:application:environment + + + Notification Endpoint + + aws:elasticbeanstalk:sns:topics + + + Protocol + HTTP + aws:elb:loadbalancer + + + Xms + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + changed description + SampleApp + 2010-11-17T19:26:20.420Z + Default + 2010-11-17T20:58:27.508Z + + + 6cbcb09a-f28d-11df-8a78-9f77047e0d0c + + +` From abc59f78690d95f382801586c88c37c1ac55092b Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 3 Nov 2014 21:45:49 +1100 Subject: [PATCH 32/33] Added UpdateEnvironment method --- eb/eb.go | 65 ++++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 39 ++++++++++++++++++++++++++ eb/responses_test.go | 22 +++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index ddcbaef8..d58c7982 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -1187,6 +1187,71 @@ func (eb *EB) UpdateConfigurationTemplate(options *UpdateConfigurationTemplate) return } +// UpdateEnvironment + +type UpdateEnvironment struct { + Description string + EnvironmentId string + EnvironmentName string + OptionSettings []ConfigurationOptionSetting + OptionsToRemove []OptionSpecification + TemplateName string + Tier EnvironmentTier + VersionLabel string +} + +type UpdateEnvironmentResp struct { + ApplicationName string `xml:"UpdateEnvironmentResult>ApplicationName"` + CNAME string `xml:"UpdateEnvironmentResult>CNAME"` + DateCreated string `xml:"UpdateEnvironmentResult>DateCreated"` + DateUpdated string `xml:"UpdateEnvironmentResult>DateUpdated"` + Description string `xml:"UpdateEnvironmentResult>Description"` + EndpointURL string `xml:"UpdateEnvironmentResult>EndpointURL"` + EnvironmentId string `xml:"UpdateEnvironmentResult>EnvironmentId"` + EnvironmentName string `xml:"UpdateEnvironmentResult>EnvironmentName"` + Health string `xml:"UpdateEnvironmentResult>Health"` + Resources EnvironmentResourceDescription `xml:"UpdateEnvironmentResult>Resources"` + SolutionStackName string `xml:"UpdateEnvironmentResult>SolutionStackName"` + Status string `xml:"UpdateEnvironmentResult>Status"` + TemplateName string `xml:"UpdateEnvironmentResult>TemplateName"` + Tier EnvironmentTier `xml:"UpdateEnvironmentResult>Tier"` + VersionLabel string `xml:"UpdateEnvironmentResult>VersionLabel"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) UpdateEnvironment(options *UpdateEnvironment) (resp *UpdateEnvironmentResp, err error) { + params := makeParams("UpdateEnvironment") + + params["Description"] = options.Description + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + params["TemplateName"] = options.TemplateName + params["VersionLabel"] = options.VersionLabel + + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+".Value"] = v.Value + } + for i, v := range options.OptionsToRemove { + params["OptionsToRemove.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionsToRemove.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + } + params["Tier.Name"] = options.Tier.Name + params["Tier.Type"] = options.Tier.Type + params["Tier.Version"] = options.Tier.Version + + resp = &UpdateEnvironmentResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index 0f654030..057436a5 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -657,3 +657,42 @@ func (s *S) TestUpdateConfigurationTemplate(c *C) { c.Assert(resp.DateUpdated, Equals, "2010-11-17T20:58:27.508Z") c.Assert(resp.RequestId, Equals, "6cbcb09a-f28d-11df-8a78-9f77047e0d0c") } + +func (s *S) TestUpdateEnvironment(c *C) { + testServer.Response(200, nil, UpdateEnvironmentExample) + + options := eb.UpdateEnvironment{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + OptionsToRemove: []eb.OptionSpecification{{ + Namespace: "aws.autoscaling.trigger", + OptionName: "MeasureName", + }}, + TemplateName: "default", + } + + resp, err := s.eb.UpdateEnvironment(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateEnvironment"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(req.Form["OptionsToRemove.member.1.Namespace"], DeepEquals, []string{"aws.autoscaling.trigger"}) + c.Assert(req.Form["OptionsToRemove.member.1.OptionName"], DeepEquals, []string{"MeasureName"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"default"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.CNAME, Equals, "SampleApp.elasticbeanstalk.amazonaws.com") + c.Assert(resp.DateCreated, Equals, "2010-11-17T20:17:42.339Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T21:05:55.251Z") + c.Assert(resp.Description, Equals, "SampleAppDescription") + c.Assert(resp.EndpointURL, Equals, "elasticbeanstalk-SampleAppVersion-246126201.us-east-1.elb.amazonaws.com") + c.Assert(resp.EnvironmentId, Equals, "e-hc8mvnayrx") + c.Assert(resp.EnvironmentName, Equals, "SampleAppVersion") + c.Assert(resp.Health, Equals, "Grey") + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Status, Equals, "Deploying") + c.Assert(resp.TemplateName, Equals, "") + c.Assert(resp.VersionLabel, Equals, "New Version") + c.Assert(resp.RequestId, Equals, "7705f0bc-f28e-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index a4acf7ad..6882aa78 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1649,3 +1649,25 @@ var UpdateConfigurationTemplateExample = ` ` + +var UpdateEnvironmentExample = ` + + + New Version + Deploying + SampleApp + elasticbeanstalk-SampleAppVersion-246126201.us-east-1.elb.amazonaws.com + SampleApp.elasticbeanstalk.amazonaws.com + Grey + e-hc8mvnayrx + 2010-11-17T21:05:55.251Z + 32bit Amazon Linux running Tomcat 7 + SampleAppDescription + SampleAppVersion + 2010-11-17T20:17:42.339Z + + + 7705f0bc-f28e-11df-8a78-9f77047e0d0c + + +` From c264747d2344defa5dc7957878bd9e2e5bc3359c Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Mon, 3 Nov 2014 21:59:21 +1100 Subject: [PATCH 33/33] Added ValidateConfigurationSettings method --- eb/eb.go | 48 ++++++++++++++++++++++++++++++++++++++++++++ eb/eb_test.go | 30 +++++++++++++++++++++++++++ eb/responses_test.go | 18 +++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/eb/eb.go b/eb/eb.go index d58c7982..52b2cc66 100644 --- a/eb/eb.go +++ b/eb/eb.go @@ -1252,6 +1252,54 @@ func (eb *EB) UpdateEnvironment(options *UpdateEnvironment) (resp *UpdateEnviron return } +// ---------------------------------------------------------------------------- +// Validate + +// ValidateConfigurationSettings + +type ValidateConfigurationSettings struct { + ApplicationName string + EnvironmentName string + OptionSettings []ConfigurationOptionSetting + TemplateName string +} + +type ValidationMessage struct { + Message string + Namespace string + OptionName string + Severity string +} + +type ValidateConfigurationSettingsResp struct { + Messages []ValidationMessage `xml:"ValidateConfigurationSettingsResult>Messages>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) ValidateConfigurationSettings(options *ValidateConfigurationSettings) (resp *ValidateConfigurationSettingsResp, err error) { + params := makeParams("ValidateConfigurationSettings") + + params["ApplicationName"] = options.ApplicationName + params["EnvironmentName"] = options.EnvironmentName + params["TemplateName"] = options.TemplateName + + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+".Value"] = v.Value + } + + resp = &ValidateConfigurationSettingsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + // ---------------------------------------------------------------------------- // Responses diff --git a/eb/eb_test.go b/eb/eb_test.go index 057436a5..c41a437b 100644 --- a/eb/eb_test.go +++ b/eb/eb_test.go @@ -696,3 +696,33 @@ func (s *S) TestUpdateEnvironment(c *C) { c.Assert(resp.VersionLabel, Equals, "New Version") c.Assert(resp.RequestId, Equals, "7705f0bc-f28e-11df-8a78-9f77047e0d0c") } + +func (s *S) TestValidateConfigurationSettings(c *C) { + testServer.Response(200, nil, ValidateConfigurationSettingsExample) + + options := eb.ValidateConfigurationSettings{ + ApplicationName: "SampleApp", + EnvironmentName: "SampleAppVersion", + OptionSettings: []eb.ConfigurationOptionSetting{{ + Namespace: "aws.autoscaling.trigger", + OptionName: "LowerThreshold", + Value: "1000000", + }}, + } + + resp, err := s.eb.ValidateConfigurationSettings(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"ValidateConfigurationSettings"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(req.Form["OptionSettings.member.1.Namespace"], DeepEquals, []string{"aws.autoscaling.trigger"}) + c.Assert(req.Form["OptionSettings.member.1.OptionName"], DeepEquals, []string{"LowerThreshold"}) + c.Assert(req.Form["OptionSettings.member.1.Value"], DeepEquals, []string{"1000000"}) + c.Assert(err, IsNil) + c.Assert(resp.Messages[0].Message, Equals, "abc") + c.Assert(resp.Messages[0].Namespace, Equals, "def") + c.Assert(resp.Messages[0].OptionName, Equals, "ghi") + c.Assert(resp.Messages[0].Severity, Equals, "warning") + c.Assert(resp.RequestId, Equals, "06f1cfff-f28f-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go index 6882aa78..7616a46f 100644 --- a/eb/responses_test.go +++ b/eb/responses_test.go @@ -1671,3 +1671,21 @@ var UpdateEnvironmentExample = ` ` + +var ValidateConfigurationSettingsExample = ` + + + + + abc + def + ghi + warning + + + + + 06f1cfff-f28f-11df-8a78-9f77047e0d0c + + +`